错误
RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.
毫无疑问,要想使用GPU,必须要安装显卡驱动,这样nvidia docker才能正常运行。
安装docker,安装nvidia
curl -s -L https://nvidia.github.io/nvidia-docker/centos7/x86_64/nvidia-docker.repo | sudo tee /etc/yum.repos.d/nvidia-docker.repo
如果报错多执行几次
下载 nvidia-docker2
查找可安装的nvidia docker版本
yum search --showduplicates nvidia-docker
安装nvidia-docker
yum install nvidia-docker-1.0.1-1.x86_64
配置docker
vim /etc/docker/daemon.json
{
"data-root": "/docker",
"default-runtime": "nvidia",
"runtimes": {
"nvidia": {
"path": "nvidia-container-runtime",
"runtimeArgs": []
}
}
}
添加一行 "default-runtime": "nvidia",
重启docker
systemctl restart docker
查看是否安装
yum list installed | grep nvidia 或者 rpm -qa | grep nvidia