ubuntu 在docker中使用gpu,安裝nvidia-container-runtime
阿新 • • 發佈:2021-07-02
1. 參考https://nvidia.github.io/nvidia-container-runtime/ 配置nvidia 源
主要執行:
curl -s -L https://nvidia.github.io/nvidia-container-runtime/gpgkey | \ sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-container-runtime/$distribution/nvidia-container-runtime.list | \sudo tee /etc/apt/sources.list.d/nvidia-container-runtime.list
sudo apt-get update
2. 參考https://gitee.com/wuxler/nvidia-container-runtime?_from=gitee_search 安裝nvidia-container-runtime
主要執行:
安裝執行時
sudo apt-get install nvidia-container-runtime
停止docker
systemctl stop docker
把執行時新增到docker中: dockerd--add-runtime=nvidia=/usr/bin/nvidia-container-runtime
建立一個容器:
建立容器時一定要指定gpus引數
docker run -it --gpus=all 映象名 執行命令
進入容器後執行
nvidia-smi
如果正常會有GPU資訊
PS: 建立容器時偌提示:
docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]]. ERRO[0000] error waiting for container: context canceled
apt-get install nvidia-container-toolkit
systemctl restart docker