docker pytorch配置

1.docker镜像更换

https://docker.xuanyuan.me/

windows

1
2
3
4
5
6
7
8
9
10
11
12
13
{
"builder": {
"gc": {
"defaultKeepStorage": "20GB",
"enabled": true
}
},
"experimental": false,
"registry-mirrors": [
"https://docker.1ms.run",
"https://docker.xuanyuan.me"
]
}

1、修改 /etc/docker/daemon.json,设置 registry mirror,具体命令如下:

1
2
3
4
5
6
7
8
sudo vim /etc/docker/daemon.json <<EOF
{
"registry-mirrors": [
"https://docker.1ms.run",
"https://docker.xuanyuan.me"
]
}
EOF

2.重启docker:

1
2
systemctl daemon-reload
systemctl restart docker

2.拉取容器

1
docker pull pytorch/pytorch

3.运行容器

1
docker run --gpus all -d -ti -v /root/test:/root/soft --name=wangguohong --ipc=host -it pytorch/pytorch:latest

进入容器

1
docker exec -e TERM=xterm-256color -it 0288d374a4a1 /bin/bash

4.打包

https://www.cnblogs.com/liftsail/p/18244202

5.挂载目录

使用 -v 参数可以将宿主机上的目录挂载到容器中的指定目录。例如,以下命令将宿主机的 /root/test 目录挂载到容器的 /root/soft 目录:

1
docker run --name test -it --privileged -v /root/test:/root/soft centos:6 /bin/bash