docker部署langchain-ChatGLM

docker部署langchain-ChatGLM

下载项目

1
2
3
4
git clone https://github.com/imClumsyPanda/langchain-ChatGLM
cd langchain-ChatGLM
git fetch --all
git checkout v0.1.14

docker 部署

在主机上安装 NVIDIA Container Toolkit

1
2
3
4
sudo apt-get update
sudo apt-get install -y nvidia-container-toolkit-base
sudo systemctl daemon-reload 
sudo systemctl restart docker

联网使用

编译镜像

1
docker build -f Dockerfile-cuda -t chatglm-cuda:latest .

启动容器

1
docker run --gpus all -d --name chatglm -p 7860:7860  chatglm-cuda:latest

使用离线模型

text2vec-large-chinese

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
cjx@cjx:/ssd2/huggingface/GanymedeNil/text2vec-large-chinese$ ll
总计 1272280
drwxrwxr-x 2 cjx cjx       4096  6月  9 20:46 ./
drwxrwxr-x 3 cjx cjx       4096  6月  9 20:45 ../
-rw-rw-r-- 1 cjx cjx        821  6月  9 20:46 config.json
-rw-rw-r-- 1 cjx cjx         69  6月  9 20:46 eval_results.txt
-rw-rw-r-- 1 cjx cjx       1477  6月  9 20:45 .gitattributes
-rw-rw-r-- 1 cjx cjx 1302223089  3月  7 11:34 pytorch_model.bin
-rw-rw-r-- 1 cjx cjx        317  6月  9 20:46 README.md
-rw-rw-r-- 1 cjx cjx        125  6月  9 20:46 special_tokens_map.json
-rw-rw-r-- 1 cjx cjx        514  6月  9 20:46 tokenizer_config.json
-rw-rw-r-- 1 cjx cjx     439387  6月  9 20:46 tokenizer.json
-rw-rw-r-- 1 cjx cjx     109540  6月  9 20:46 vocab.txt

ChatGLM-6B

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
cjx@cjx:/ssd2/github/THUDM/ChatGLM-6B/chatglm-6b$ ll
总计 13105340
drwxrwxr-x  3 cjx cjx       4096  5月 22 14:55 ./
drwxrwxr-x 10 cjx cjx       4096  5月 22 15:18 ../
-rw-rw-r--  1 cjx cjx        773  5月 22 14:43 config.json
-rw-rw-r--  1 cjx cjx       4276  5月 22 14:43 configuration_chatglm.py
drwxrwxr-x  8 cjx cjx       4096  5月 22 14:43 .git/
-rw-rw-r--  1 cjx cjx       1477  5月 22 14:43 .gitattributes
-rw-rw-r--  1 cjx cjx    2706249  5月 22 14:44 ice_text.model
-rw-rw-r--  1 cjx cjx      11336  5月 22 14:44 LICENSE
-rw-rw-r--  1 cjx cjx      57620  5月 22 14:43 modeling_chatglm.py
-rw-rw-r--  1 cjx cjx       2354  5月 22 14:44 MODEL_LICENSE
-rw-rw-r--  1 cjx cjx 1740651802  5月 22 14:53 pytorch_model-00001-of-00008.bin
-rw-rw-r--  1 cjx cjx 1879731432  5月 22 14:53 pytorch_model-00002-of-00008.bin
-rw-rw-r--  1 cjx cjx 1980385902  5月 22 14:53 pytorch_model-00003-of-00008.bin
-rw-rw-r--  1 cjx cjx 1913294120  5月 22 14:53 pytorch_model-00004-of-00008.bin
-rw-rw-r--  1 cjx cjx 1879722289  5月 22 14:53 pytorch_model-00005-of-00008.bin
-rw-rw-r--  1 cjx cjx 1879731496  5月 22 14:53 pytorch_model-00006-of-00008.bin
-rw-rw-r--  1 cjx cjx 1074103621  5月 22 14:50 pytorch_model-00007-of-00008.bin
-rw-rw-r--  1 cjx cjx 1069286123  5月 22 14:50 pytorch_model-00008-of-00008.bin
-rw-rw-r--  1 cjx cjx      33416  5月 22 14:43 pytorch_model.bin.index.json
-rw-rw-r--  1 cjx cjx      15054  5月 22 14:43 quantization.py
-rw-rw-r--  1 cjx cjx       6087  5月 22 14:43 README.md
-rw-rw-r--  1 cjx cjx      13822  5月 22 14:43 test_modeling_chatglm.py
-rw-rw-r--  1 cjx cjx      17047  5月 22 14:43 tokenization_chatglm.py
-rw-rw-r--  1 cjx cjx        441  5月 22 14:43 tokenizer_config.json

修改配置

configs/model_config

1
2
3
# 如果你需要加载本地的model,指定这个参数  ` --no-remote-model`,或者下方参数修改为 `True`
# NO_REMOTE_MODEL = False
NO_REMOTE_MODEL = True

编译镜像

1
docker build -f Dockerfile-cuda -t chatglm-cuda:latest .

启动容器

配置好模型路径,然后此repo挂载到Container

1
2
3
4
5
6
docker run --gpus all -d \
  --name chatglm \
  -p 7860:7860 \
  -v /ssd2/huggingface/GanymedeNil/text2vec-large-chinese:/chatGLM/GanymedeNil/text2vec-large-chinese \
  -v /ssd2/github/THUDM/ChatGLM-6B/chatglm-6b:/chatGLM/model/chatglm-6b \
  chatglm-cuda:latest
comments powered by Disqus