![](https://img.haomeiwen.com/i925416/4078040fd12f17a8.png)
一、宿主机安装Cuda
1.1 nouveau 驱动问题
nouveau 是系统自带的一个显示驱动程序,需要先将其禁用,然后再进行下一步操作,否则在安装显卡驱动时,会提示:You appear to be running an X server …,然后安装失败。分别打开如下两个文件(如果没有就创建一个),并在其中输入如下两句,然后保存。
vim /etc/modprobe.d/nvidia-installer-disable-nouveau.conf
vim /lib/modprobe.d/nvidia-installer-disable-nouveau.conf
blacklist nouveau
options nouveau modeset=0
1.2 GCC问题
太容易忽略
1.3Kernel问题
# 资料 https://unix.stackexchange.com/questions/115289/driver-install-kernel-source-not-found
yum -y install kernel-devel kernel-header
二、Docker 安装
2.1 Ubuntu安装
# 直接这么安装,别折腾了。
apt install docker
2.2 Centos安装
# 别折腾了 哥
yum install docker
三、NVIDIA-DOCKER
3.1 Ubuntu 14.04/16.04/18.04, Debian Jessie/Stretch
Ubuntu will install docker.io
by default which isn't the latest version of Docker Engine. This implies that you will need to pin the version of nvidia-docker. See more information here.
# If you have nvidia-docker 1.0 installed: we need to remove it and all existing GPU containers
docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -f
sudo apt-get purge -y nvidia-docker
# Add the package repositories
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \
sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \
sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update
# Install nvidia-docker2 and reload the Docker daemon configuration
sudo apt-get install -y nvidia-docker2
sudo pkill -SIGHUP dockerd
# Test nvidia-smi with the latest official CUDA image
docker run --runtime=nvidia --rm nvidia/cuda:9.0-base nvidia-smi
3.2 CentOS 7 (docker-ce), RHEL 7.4/7.5 (docker-ce), Amazon Linux 1/2
If you are not using the official docker-ce
package on CentOS/RHEL, use the next section.
# If you have nvidia-docker 1.0 installed: we need to remove it and all existing GPU containers
docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -f
sudo yum remove nvidia-docker
# Add the package repositories
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.repo | \
sudo tee /etc/yum.repos.d/nvidia-docker.repo
# Install nvidia-docker2 and reload the Docker daemon configuration
sudo yum install -y nvidia-docker2
sudo pkill -SIGHUP dockerd
# Test nvidia-smi with the latest official CUDA image
docker run --runtime=nvidia --rm nvidia/cuda:9.0-base nvidia-smi
If yum
reports a conflict on /etc/docker/daemon.json
with the docker
package, you need to use the next section instead.
For docker-ce on ppc64le
, look at the FAQ.
3.3 CentOS 7 (docker), RHEL 7.4/7.5 (docker)
# If you have nvidia-docker 1.0 installed: we need to remove it and all existing GPU containers
docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -f
sudo yum remove nvidia-docker
# Add the package repositories
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
# Install the nvidia runtime hook
sudo yum install -y nvidia-container-runtime-hook
# Test nvidia-smi with the latest official CUDA image
# You can't use `--runtime=nvidia` with this setup.
docker run --rm nvidia/cuda:9.0-base nvidia-smi
3.4 Docker与当前Nvidia-docker版本不一致
查找可安装的nvidia docker版本
yum search --showduplicates nvidia-docker
最终输出结果是下面这张图:
查找可安装的nvidia docker
版本
yum search --showduplicates nvidia-docker1
最终输出结果是下面这张图:
大家可以从中选择自己需要安装的nvidia docker
版本,这里我安装的是docker
是1.12.6
版本的。因此我选择安装倒数第一个版本的nvidia docker
。
可以去参考资料1去看博客.
网友评论