浏览代码

supports GPU usage in docker (#196)

Co-authored-by: Huaiyong <huaiyong.sun@hpe.com>
cocomany 2 年之前
父节点
当前提交
66b104d26a
共有 2 个文件被更改,包括 27 次插入4 次删除
  1. 13 0
      Dockerfile-cuda
  2. 14 4
      README.md

+ 13 - 0
Dockerfile-cuda

@@ -0,0 +1,13 @@
+FROM  nvidia/cuda:12.1.0-runtime-ubuntu20.04
+LABEL MAINTAINER="chatGLM"
+
+COPY . /chatGLM/
+
+WORKDIR /chatGLM
+
+RUN apt-get update -y && apt-get install python3 python3-pip curl -y  && apt-get clean
+RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python3 get-pip.py 
+
+RUN pip3 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn && rm -rf `pip3 cache dir`
+
+CMD ["python3","-u", "webui.py"]

+ 14 - 4
README.md

@@ -37,13 +37,23 @@
     本项目中默认选用的 Embedding 模型 [GanymedeNil/text2vec-large-chinese](https://huggingface.co/GanymedeNil/text2vec-large-chinese/tree/main) 约占用显存 3GB,也可修改为在 CPU 中运行。
 
 ## Docker 部署
+为了能让容器使用主机GPU资源,需要在主机上安装 [NVIDIA Container Toolkit](https://github.com/NVIDIA/nvidia-container-toolkit)。具体安装步骤如下:
+```shell
+sudo apt-get update
+sudo apt-get install -y nvidia-container-toolkit-base
+sudo systemctl daemon-reload 
+sudo systemctl restart docker
+```
+安装完成后,可以使用以下命令编译镜像和启动容器:
+```
+docker build -t chatglm-cuda:latest .
+docker run --gpus all -d --name chatglm -p 7860:7860  chatglm-cuda:latest
 
-```commandline
-$ docker build -t chatglm:v1.0 .
-
-$ docker run -d --restart=always --name chatglm -p 7860:7860 -v /www/wwwroot/code/langchain-ChatGLM:/chatGLM  chatglm
+#若要使用离线模型,请配置好模型路径,然后此repo挂载到Container
+docker run --gpus all -d --name chatglm -p 7860:7860 -v ~/github/langchain-ChatGLM:/chatGLM  chatglm-cuda:latest
 ```
 
+
 ## 开发部署
 
 ### 软件需求