docker中使用GPU
最后发布时间 : 2024-09-01 13:14:09
浏览量 :
github项目https://github.com/chatchat-space/Langchain-Chatchat使用docker容器启动时使用以下命令
docker run -d --gpus all -p 80:8501 registry.cn-beijing.aliyuncs.com/chatchat/chatchat:0.2.7
如果docker gpu没有安装好将报错如下
docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]]. AFTER installing nvidia-docker2
解决方案参考stackoverflow
Configure the repository:
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
&& curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list |
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' |
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
&&
sudo apt-get update
Install the NVIDIA Container Toolkit packages:
sudo apt-get install -y nvidia-container-toolkit
Configure the container runtime by using the nvidia-ctk command:
sudo nvidia-ctk runtime configure --runtime=docker
Restart the Docker daemon:
sudo systemctl restart docker
上述解决方案的前提是gpu驱动已经安装成功,查看gpu驱动是否安装成功可以参考这篇文章、安装NVIDIA显卡、安装NVIDIA显卡
nvidia-smi # 确认有显卡以后输入下面命令,以检查之前是否安装了驱动。
ubuntu-drivers devices # 如果发现没有安装过驱动,则可再输入下面命令,以查看显卡型号以及推荐的驱动版本
sudo ubuntu-drivers autoinstall # 安装驱动
nvidia-docker
https://hub.docker.com/r/windj007/jupyter-keras-tools
物理机显卡驱动安装
ubuntu 查看是否存在显卡
lspci | grep -i vga
docker run --gpus all -p 8089:8089 -p 8001:8000 --rm -it -v /data/llm:/data/llm huggingface/transformers-pytorch-gpu /data/llm/ChatGLM-6B/run.sh
docker run -d --gpus all -p 8089:8089 -p 8001:8000 --rm -it -v /data/llm:/data/llm huggingface/transformers-pytorch-gpu jupyter-lab --port=8089 --NotebookApp.token='' --allow-root --ip=0.0.0.0