Ubuntu installation NVIDIA-Docker detailed tutorial (offline && online)

insert image description here
Station B|Official account: a graduate student who knows everything

Docker installation

Although the installation steps were described in detail in the previous post, Ubuntu installation, uninstallation of Docker, common mirroring, container operation commands , but the summary is written here

sudo apt-get remove docker docker-engine docker.io ###清除系统原有docker 如果提示找不到不用理会 

sudo apt-get update ###更新apt-get源 

sudo apt-get install apt-transport-https ca-certificates curl software-properties-common ###安装docker的依赖 

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

sudo apt-key fingerprint 0EBFCD88

sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu \ 
$(lsb_release -cs) \ 
stable”
 sudo apt-get update
 sudo apt-get install docker-ce docker-ce-cli containerd.io
sudo docker run hello-world #运行成功则表示安装成功

Install NVIDIA-Docker online

https://github.com/NVIDIA/nvidia-docker/

Requires an agent to install.

First confirm that the nvidia driver has been installed, you can use the nvidia-smi command to view

curl https://get.docker.com | sh
sudo systemctl start docker && sudo systemctl enable docker

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

sudo apt-get update
sudo apt-get install -y nvidia-docker2
sudo systemctl restart docker

(Recommendation) Install NVIDIA-Docker Offline

The offline files have been packaged and put into the cloud disk. In order to prevent the link from frequently hanging up, I put the link on the official account [Graduate student who knows everything], so that it can be updated immediately. Reply to [docker] to get it. After the download is complete, execute the following in
sequence Order

sudo dpkg -i libnvidia-container1_1.2.0-1_amd64.deb
sudo dpkg -i libnvidia-container-tools_1.2.0-1_amd64.deb
sudo dpkg -i nvidia-container-toolkit_1.2.1-1_amd64.deb
sudo dpkg -i nvidia-container-runtime_3.3.0-1_amd64.deb
sudo dpkg -i nvidia-docker2_2.4.0-1_all.deb
sudo systemctl restart docker

Notice

After installing nvidia-docker, you need to add --gpus all
such as sudo docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi
entering the container to start the container nvidia-smi, and the displayed information means success

Guess you like

Origin blog.csdn.net/zzh516451964zzh/article/details/128992983