【分布式训练】基于docker容器的pytorch多机分布式训练
·
参考链接
Deep Learning:PyTorch 基于docker 容器的分布式训练实践
基于Docker的大规模人脸数据集分布式训练
Ubuntu安装docker
ubuntu下自带了docker的库,不需要添加新的源。
但是ubuntu自带的docker版本太低,需要先卸载旧的再安装新的。
1、卸载旧版本
apt-get remove docker docker-engine docker.io containerd runc
使用apt-get命令时,如果出现Could not get lock /var/lib/dpkg/lock-frontend,说明之前使用apt时出现异常,没有正常关闭,还在运行。

解决:使用ps 和 grep查找apt的pid,并使用kill杀死掉
参考Could not get lock /var/lib/dpkg/lock-frontend解决
ps afx|grep apt
kill 3652
kill 3656

2、安装前提依赖
apt update
apt-get install ca-certificates curl gnupg lsb-release
3、安装GPG证书
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
4、写入软件源信息
add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
5、安装新版本
apt-get install docker-ce docker-ce-cli containerd.io
6、配置用户组
groupadd docker
7、启动docker
systemctl start docker
8、docker换源
使用中科大的源
# 修改 /etc/docker/daemon.json (如果该文件不存在,则创建)
{
"registry-mirrors": [
"https://docker.mirrors.ustc.edu.cn"
]
}
9、必要工具
安装必要的一些系统工具
apt-get -y install apt-transport-https ca-certificates curl software-properties-common
10、重启 docker
systemctl restart docker
11、查看docker运行情况
systemctl status docker

12、运行 hello-world
docker run hello-world

若出现以下报错,检查/etc/docker/daemon.json文件是否有错误
root@ubuntu:/home/wuwenjing/Desktop# docker run hello-world
Unable to find image 'hello-world:latest' locally
标准的/etc/docker/daemon.json文件如下图:

pull docker镜像
docker pull loongc/pytorch:pytorch
# 机器 1
docker run -it --rm -v /mnt/pytorch/:/pytorch -w /pytorch --net=host loongc/pytorch:pytorch python mnist.py --rank 0 --world-size 1 --init-method tcp://172.16.114.1285:9090 --backend gloo
更多推荐



所有评论(0)