【docker】配置深度学习环境

以配置pytorch为例

step 1: 在docker hub上下载镜像
step 2:配置所跑代码需要的环境(采用pip)

pip install -i http://pypi.douban.com/simple/ --trusted-host=pypi.douban.com mmcv opencv-python scipy tb-nightly networkx scikit-image matplotlib future lmdb

step 3:更换apt源
           还有一些包我们是需要通过apt-get install来安装的,因此必须要apt-get update 。但是由于apt源的问题,会导致apt-get update 的速度非常慢。因此需要将其换成国内源。

cp /etc/apt/sources.list /etc/apt/sources.list.bak  #备份下
rm -r /etc/apt/sources.list   #删除原本的
touch /etc/apt/sources.list   #创建新的
#因为目前没有vim命令,只能通过echo向文件中添加
echo deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse >> /etc/apt/sources.list
echo deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse multiverse >> /etc/apt/sources.list
echo deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse >> /etc/apt/sources.list
echo deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse >> /etc/apt/sources.list
#更新
apt-get update
#安装vim 为了以后方便
apt-get install vim
#axel是用与在终端下载软件的包
apt-get install axel

step 4:下载预训练的模型

axel https://download.pytorch.org/models/vgg19-dcbb9e9d.pth

将其移入/root/.cache/torch/checkpoints/vgg19-dcbb9e9d.pth

mv vgg19-dcbb9e9d.pth /root/.cache/torch/checkpoints/

 docker命令

docker images #查看镜像
docker rmi imageID #删除镜像

docker ps #查看正在运行容器
docker ps -a #查看所有容器
docker rm ContainerID #删除容器

docker run -it imageID bash #创建一个容器运行镜像(-it 表示可交互) 可以在里面利用pip或者conda配置环境
docker commit ContainerID newImage #将某容器中的环境制作成新的镜像
docker push newImage  #推送镜像

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值