Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Docker with GPU inference. #154

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## use pytorch images
FROM pytorch/pytorch:2.0.1-cuda11.7-cudnn8-runtime
## lables
LABEL version="v1"
LABEL description="chatglm2-6b docker images"
LABEL maintainer="dengsgo[https://github.com/dengsgo]"
## copy all files
COPY . .
## install tools
RUN apt update && apt install -y git gcc
## install requirements and cudatoolkit
RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/ && \
pip install icetk -i https://pypi.tuna.tsinghua.edu.cn/simple/ && \
conda install cudatoolkit=11.7 -c nvidia
## expose port
EXPOSE 7860
## run
CMD [ "python3","web_demo.py" ]

## command for docker run
## docker run --rm -it -v /home/dengsgo/models/chatglm2-6b-int4:/workspace/THUDM/chatglm2-6b --gpus=all -e NVIDIA_DRIVER_CAPABILITIES=compute,utility -e NVIDIA_VISIBLE_DEVICES=all -p 7860:7860 chatglm2:v1
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,15 @@ pip install -r requirements.txt
```
其中 `transformers` 库版本推荐为 `4.30.2`,`torch` 推荐使用 2.0 及以上的版本,以获得最佳的推理性能。

### Docker webUI
首先需要下载本仓库:
```shell
git clone https://github.com/THUDM/ChatGLM2-6B
cd ChatGLM2-6B
docker build -t chatglm2:v1 .
docker run --rm -it -v /home/dengsgo/models/chatglm2-6b-int4:/workspace/THUDM/chatglm2-6b --gpus=all -e NVIDIA_DRIVER_CAPABILITIES=compute,utility -e NVIDIA_VISIBLE_DEVICES=all -p 7860:7860 chatglm2:v1
```

### 代码调用

可以通过如下代码调用 ChatGLM2-6B 模型来生成对话:
Expand Down
2 changes: 1 addition & 1 deletion web_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ def reset_state():

emptyBtn.click(reset_state, outputs=[chatbot, history, past_key_values], show_progress=True)

demo.queue().launch(share=False, inbrowser=True)
demo.queue().launch(share=False, inbrowser=True, server_name="0.0.0.0")