nvidia-docker安装需要安装Docker- CE、NVIDIA Container Toolkit
使用官网提供的安装指令,默认是安装最新版本的Docker
curl https://get.docker.com | sh \
&& sudo systemctl --now enable docker
注意:If you already have Docker installed, this script can cause trouble, which is
why we’re displaying this warning and provide the opportunity to cancel the
installation.
If you installed the current Docker package using this script and are using it
again to update Docker, you can safely ignore this message.
用这个指令安装Docker,后续也可以该指令更新Docker,否则请不要运行该指令,可能会出现一些错误。如果已经运行可以在看到上述提示后按住Ctrl+c停止运行脚本
使用sudo /lib/systemd/systemd-sysv-install enable docker
激活Docker,并查看Docker版本
sudo /lib/systemd/systemd-sysv-install enable docker
docker --version
设置稳定版的库源/GPG密钥
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
&& curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - \
&& curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
如果需要使用到实验特性,可将experimental分支加入库源中,否则跳过此步骤
curl -s -L https://nvidia.github.io/nvidia-container-runtime/experimental/$distribution/nvidia-container-runtime.list | sudo tee /etc/apt/sources.list.d/nvidia-container-runtime.list
更新包列表,下载安装nvidia-docker2
sudo apt-get update
sudo apt-get install -y nvidia-docker2
安装完成后重启docker,之后可通过运行CUDA base容器验证,需要选择CUDA驱动对应的版本
sudo systemctl restart docker
sudo docker run --rm --gpus all nvidia/cuda:11.2.0-base-ubuntu18.04 nvidia-smi
nvidia-docker run -it -v $PWD:/work registry.baidubce.com/paddlepaddle/paddle:2.3.2-gpu-cuda11.2-cudnn8 /bin/bash
注意:前提是物理机已经安装GPU驱动
查看python中paddlepaddle是否安装成功
通过nvidia-smi
指令查看验证GPU