docker 安装
sudo apt-get update
sudo apt-get install -y docker.io 或者snap install docker
systemctl start docker
systemctl enable docker
docker version
安装NVIDIA Container Toolkit
# 1、添加源
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
sudo curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
sudo curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
# 2、安装并重启
sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
sudo systemctl restart docker
# 3、测试
docker run --name test1 -it --gpus all或者写"device=0"或者'"device=0,1,2,3"' nvidia/cuda:10.0-base
docker 配置
vi /etc/docker/daemon.json
{
"registry-mirrors" : [
"https://jkfdsf2u.mirror.aliyuncs.com",
"https://registry.docker-cn.com"
],
"insecure-registries" : [
"docker-registry.zjq.com"
],
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "10"
},
"data-root": "/data/docker"
}
修改完成后reload配置文件
sudo systemctl daemon-reload
重启docker服务
sudo systemctl restart docker.service
查看状态
sudo systemctl status docker -l
查看服务
sudo docker info
namespace 配置
vi /etc/resolv.conf
nameserver 8.8.4.4