docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]]
在docker创建容器加 --gpus all 的时候:
docker run -itd --rm --name spvconv1 --gpus all -v /syy:/home/lcbryant/syy royokong/torch1.6.0-cuda10.1-apex-base:latest
报出如下错误:
docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]].
解决方案
1.安装nvidia驱动
确认已安装NVIDIA卡
lspci -vv | grep -i nvidia
2.安装NVIDIA Container Runtime
先预装好一些环境,新建一个nvidia-container-runtime-script.sh,内容如下:
sudo curl -s -L https://nvidia.github.io/nvidia-container-runtime/gpgkey | \
sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
sudo 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
然后运行:
sudo bash nvidia-container-runtime-script.sh
安装NVIDIA Container Runtime:
sudo apt-get install nvidia-container-runtime
查看是否装好:
which nvidia-container-runtime-hook
结果是:
3.验证
验证docker是否装好:
docker version
验证一下gpus选项:
docker run --help | grep -i gpus
然后就可以愉快地在docker容器里使用gpu啦!
|