nvidia-docker安装需要安装Docker- CE、NVIDIA Container Toolkit
Docker-CE安装
使用官网提供的安装指令,默认是安装最新版本的Docker
curl https://get.docker.com |sh\&&sudo systemctl --now enabledocker
注意: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 enabledockerdocker --version
NVIDIA Container Toolkit安装
设置稳定版的库源/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 |sudotee /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
sudoapt-get update
sudoapt-getinstall -y nvidia-docker2
安装完成后重启docker,之后可通过运行CUDA base容器验证,需要选择CUDA驱动对应的版本
sudo systemctl restart dockersudodocker run --rm --gpus all nvidia/cuda:11.2.0-base-ubuntu18.04 nvidia-smi
nvidia-docker执行GPU训练
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
版权归原作者 鳄鱼儿 所有, 如有侵权,请联系我们删除。