在GCP(谷歌云)上部署 ChatGLM-6B

1 机器准备

GCP,GPU至少选Tesla T4、操作系统Ubuntu 20.04,硬盘50GB

2 安装cuda驱动

参考GCP的官方文档:https://cloud.google.com/compute/docs/gpus/install-drivers-gpu

可以使用自动安装脚本(注意提前安装python 3)

下载

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
curl https://raw.githubusercontent.com/GoogleCloudPlatform/compute-gpu-installation/main/linux/install_gpu_driver.py --output install_gpu_driver.py
curl https://raw.githubusercontent.com/GoogleCloudPlatform/compute-gpu-installation/main/linux/install_gpu_driver.py --output install_gpu_driver.py
curl https://raw.githubusercontent.com/GoogleCloudPlatform/compute-gpu-installation/main/linux/install_gpu_driver.py --output install_gpu_driver.py

安装

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo python3 install_gpu_driver.py
sudo python3 install_gpu_driver.py
sudo python3 install_gpu_driver.py

3 安装git lfs

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
sudo apt-get install git-lfs
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash sudo apt-get install git-lfs
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash

sudo apt-get install git-lfs

4 安装pip

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo apt-get install python3-pip
sudo apt-get install python3-pip
sudo apt-get install python3-pip

5 下载代码

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
git clone https://github.com/THUDM/ChatGLM-6B.git
git clone https://github.com/THUDM/ChatGLM-6B.git
git clone https://github.com/THUDM/ChatGLM-6B.git

6 安装依赖库

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
cd ChatGLM-6B/
sudo pip install -r ./requirements.txt
cd ChatGLM-6B/ sudo pip install -r ./requirements.txt
cd ChatGLM-6B/

sudo pip install -r ./requirements.txt

7 安装Web Demo

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# 改文件,开放远程端口
demo.queue().launch(server_name='0.0.0.0', share=False, inbrowser=True)
# 改文件,开放远程端口 demo.queue().launch(server_name='0.0.0.0', share=False, inbrowser=True)
# 改文件,开放远程端口
demo.queue().launch(server_name='0.0.0.0', share=False, inbrowser=True)

启动,这个过程会下载模型,很慢,大概需要15GB硬盘

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
python3 web_demo.py
python3 web_demo.py
python3 web_demo.py

访问:http://IP:7860/

 

Leave a Reply

Your email address will not be published. Required fields are marked *