之前ubuntu安装的可以查看之前笔记:https://sulao.cn/post/919.html
centos上安装也很简单,首先设置存储库和 GPG 密钥
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) curl -s -L https://nvidia.github.io/nvidia-container-runtime/$distribution/nvidia-container-runtime.repo | \ sudo tee /etc/yum.repos.d/nvidia-container-runtime.repo
然后安装nvidia-container-runtime
yum install nvidia-container-runtime
安装完成以后也需要修改docker的配置文件daemon.json文件
cat /etc/docker/daemon.json { "default-runtime": "nvidia", "runtimes": { "nvidia": { "path": "/usr/bin/nvidia-container-runtime", "runtimeArgs": [] } } }
改完以后重启docker然后使用如下命令进行验证
docker run --rm nvidia/cuda:9.0-base nvidia-smi