0
点赞
收藏
分享

微信扫一扫

ubuntu篇---用官方pytorch-gpu版创建自己的镜像

成义随笔 2022-03-17 阅读 93

用官方pytorch-gpu版创建自己的镜像

显卡驱动、镜像cuda版本、pytorch cuda版本三者对应可以看我的另一篇博客

pytorch_gpu

构建Dockerfile

基于pytorch给定的创建dockerfile

资料下载
链接: https://pan.baidu.com/s/1tTrtEbezHR7_0Qc_ZHyeFA 密码: tjee

FROM pytorch/pytorch:1.11.0-cuda11.3-cudnn8-runtime

MAINTAINER yyq

ENV DEBIAN_FRONTEND=noninteractive
#更新pip,并且换源
RUN pip install pip -U # 升级pip到最新版本
RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

#为了运行apt-get update
RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak
COPY sources.list /etc/apt/sources.list
RUN chmod a+x /etc/apt/sources.list

#更新apt
RUN apt-get update
#安装依赖
RUN apt-get install gcc -y && apt-get install make -y \
		&& apt-get install vim -y && apt-get install openssl -y \
		&& apt-get install libssl-dev -y && apt-get install python3-pip -y

RUN apt-get install vim ffmpeg libsm6 libxext6 cron openssh-server -y
RUN pip install aio-pika==7.1.0 asyncio==3.4.3 APScheduler==3.7.0 matplotlib==3.3.4 opencv-python==4.5.2.52 && \
    Pillow==8.2.0 pika==1.2.0 pymongo==3.11.4 requests==2.25.1

RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai'>/etc/timezone

RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/'  /etc/ssh/sshd_config
RUN sed -i 's/UsePAM yes/UsePAM no/' /etc/ssh/sshd_config
RUN echo "root:123456" | chpasswd

RUN echo  "alias ll='ls -l'" >> ~/.bash_profile
RUN /bin/bash -c 'source  ~/.bash_profile;'

CMD [""]

创建环境

docker build -t py_11.3 .

构建开始
在这里插入图片描述
构建完成,并查看镜像
在这里插入图片描述# 创建容器

docker run --name py_11.3_gpu --runtime=nvidia -it py_11.3:latest /bin/bash

注:创建容器的时候一定要加 --runtime=nvidia 否则无法使用GPU

在这里插入图片描述
至此,构建完成!!!

举报

相关推荐

0 条评论