zl程序教程

您现在的位置是:首页 >  其它

当前栏目

Cuda 11/10的Dockerfile

10 11 CUDA Dockerfile
2023-09-14 09:15:32 时间

说明:如果NVIDIA显卡不满足要求,请修改dockerfile文件配置要求或慎重使用,关于dockerfile使用请参考我的博客文章:
https://blog.csdn.net/weixin_41194129/category_10210023.html
在这里插入图片描述

cuda11相关链接如下:
https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/
https://github.com/triton-inference-server/server/releases/tag/v2.7.0
https://github.com/Algorithm-learning-community-for-python/project_dockerfile/tree/master/cuda11

https://github.com/EnzoDAndrea/Container-TF2.4-CUDA-11

CUDA10.1-ubuntu16.04:

安装Docker 参考ubuntu安装docker
安装NVIDIA Container Toolkit 参考NVIDIA/nvidia-docker
准备好Python-3.6.9.tar.xz
从nvidia/cuda:10.0-cudnn7-devel-ubuntu16.04 镜像基础上搭建
安装openssh-server、python、pytorch
run镜像时加上参数--gpus all --ipc=host
# BASE IMAGE
FROM nvidia/cuda:10.0-cudnn7-devel-ubuntu16.04 

# LABEL MAINTAINER
LABEL xxx="xxx@xxx"

SHELL ["/bin/bash","-c"]

WORKDIR /tmp
# copy安装文件
COPY Python-3.6.9.tar.xz /tmp
# 设置 root 密码
RUN echo 'root:password' | chpasswd \
# 安装openssh-server 并配置
  && apt-get update && apt-get -y install openssh-server \
  && sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config \ 
  && sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config \
  && mkdir /var/run/sshd \
# 安装python依赖包
  && apt-get -y install build-essential python-dev python-setuptools python-pip python-smbus \
  && apt-get -y install build-essential libncursesw5-dev libgdbm-dev libc6-dev \
  && apt-get -y install zlib1g-dev libsqlite3-dev tk-dev \
  && apt-get -y install libssl-dev openssl \
  && apt-get -y install libffi-dev \
# 安装python 3.6.9
  && mkdir -p /usr/local/python3.6 \
  && tar xvf Python-3.6.9.tar.xz \
  && cd Python-3.6.9 \
  && ./configure --prefix=/usr/local/python3.6 \
  && make altinstall \
# 建立软链接
  && ln -snf /usr/local/python3.6/bin/python3.6 /usr/bin/python3 \
  && ln -snf /usr/local/python3.6/bin/pip3.6 /usr/bin/pip3\
# 安装pytorch
  && mkdir ~/.pip && echo -e '[global] \nindex-url = https://mirrors.aliyun.com/pypi/simple/' >> ~/.pip/pip.conf \
  && pip3 install torch===1.2.0 torchvision===0.4.0 -f https://download.pytorch.org/whl/torch_stable.html \
# 清理copy的安装文件
  && apt-get clean \
  && rm -rf /tmp/* /var/tmp/*

EXPOSE 22

CMD ["/usr/sbin/sshd", "-D"]

构建镜像命令:
docker build -t dockerfile .