分享一个此项目环境的Dockerfile

Dockerfile:

FROM nvidia/cuda:12.0.1-devel-ubuntu20.04

COPY sources.list /etc/apt/sources.list

ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Asia/Shanghai

RUN apt-get update && \ 
    apt-get install -y python3.9 && \
    apt-get install -y python3-pip && \
    apt-get clean

RUN groupadd -g 1000 user && adduser user --gid 1000 --uid 1000

USER user
WORKDIR /home/user

COPY requirements.txt requirements.txt

RUN pip3 config set global.index-url https://mirrors.aliyun.com/pypi/simple && \
    pip3 config set install.trusted-host mirrors.alirun.com && \
    pip3 install -r ~/requirements.txt

RUN echo 'export PATH=${PATH}:/home/user/.local/bin' >> .bashrc

sources.list:

deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse

# deb https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

requirements.txt

torch==1.12.0
torchvision==0.13.0
torchaudio==0.12.0
d2l==0.17.6