Enter the following commands in order
$ curl -fsSL get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh --mirror Aliyun
$ sudo systemctl enable docker
$ sudo systemctl start docker
$ sudo groupadd docker
$ sudo usermod -aG docker $USER
$ sudo docker run hello-world
$ 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
$ sudo apt-get install -y nvidia-docker2
$ sudo pkill -SIGHUP dockerd
$ nvidia-docker --version
pull image
$ sudo docker pull pytorch/pytorch:1.13.1-cuda11.6-cudnn8-runtime # 这步时间挺长的
$ sudo nvidia-docker run -itd -p 5004:22 pytorch/pytorch:1.13.1-cuda11.6-cudnn8-runtime
Query the ID of the container
$ sudo docker ps
log into the container
$ sudo docker exec -it cb52a1489e3a /bin/bash
initialization
$ conda init
View installed packages
$ conda list
View graphics card information
$ nvcc -V
Reference link:
https://zhuanlan.zhihu.com/p/44962017
https://blog.csdn.net/weixin_43332715/article/details/124414577?spm=1001.2014.3001.5501
https://blog.csdn.net/weixin_43332715 /article/details/124422461?spm=1001.2014.3001.5501
https://blog.csdn.net/weixin_43332715/article/details/124431047
https://hub.docker.com/r/pytorch/pytorch/tags?page=1&ordering =last_updated