Skip to content

Commit

Permalink
Merge pull request hiyouga#21 from michaeloo0/main
Browse files Browse the repository at this point in the history
Temporarily deploy the ChatGLM fintune model running on colab through cloudfare tunnel
  • Loading branch information
hiyouga authored Apr 23, 2023
2 parents 7a93038 + e1a9f5c commit 3f6b6cb
Showing 1 changed file with 143 additions and 0 deletions.
143 changes: 143 additions & 0 deletions cloudflare-tunnel-to-colab.py.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"1. Download **ChatGLM-Efficient-Tuning** repo."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": [
"!git clone https://github.com/hiyouga/ChatGLM-Efficient-Tuning.git"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"2. Install requirements."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": [
"!pip install -r /content/ChatGLM-Efficient-Tuning/requirements.txt"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"3. Download your finetune checkpoint"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": [
"!git clone git lfs install\n",
"!git clone https://huggingface.co/your-finetune-checkpoint"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"4. Download cloudfared"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": [
"!wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -O cloudflared\n",
"!chmod a+x cloudflared"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"5. Deploy the finetune model"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": [
"import nest_asyncio\n",
"nest_asyncio.apply()\n",
"\n",
"import subprocess\n",
"print(\"start cloudflared runnel\")\n",
"f = open(\"stdout\", \"w\")\n",
"p = subprocess.Popen(['./cloudflared', '--url', 'http://localhost:7860'], bufsize=0, stdout=f, stderr=subprocess.STDOUT)\n",
"\n",
"import time\n",
"\n",
"time.sleep(3)\n",
"\n",
"!grep -F trycloudflare stdout\n",
"\n",
"!CUDA_VISIBLE_DEVICES=0 python /content/ChatGLM-Efficient-Tuning/src/web_demo.py \\\n",
" --checkpoint_dir /content/your-finetune-checkpoint"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"1. Open the link in the third line of the figure, you can share the link to any who want to try your finetune model.\n",
"![image](https://i.imgur.com/b9LWJcZ.png)"
]
}
],
"metadata": {
"language_info": {
"name": "python"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit 3f6b6cb

Please sign in to comment.