File size: 3,922 Bytes
2916d61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# PaperspaceのGradient環境での学習環境構築用Dockerfileです。
# 環境のみ構築するため、イメージには学習用のコードは含まれていません。
# 以下を参照しました。
# https://github.com/gradient-ai/base-container/tree/main/pt211-tf215-cudatk120-py311

# 主なバージョン等
# Ubuntu 22.04
# Python 3.10
# PyTorch 2.1.2 (CUDA 11.8)
# CUDA Toolkit 12.0, CUDNN 8.9.7


# ==================================================================
# Initial setup
# ------------------------------------------------------------------

# Ubuntu 22.04 as base image
FROM ubuntu:22.04
# RUN yes| unminimize

# Set ENV variables
ENV LANG C.UTF-8
ENV SHELL=/bin/bash
ENV DEBIAN_FRONTEND=noninteractive

ENV APT_INSTALL="apt-get install -y --no-install-recommends"
ENV PIP_INSTALL="python3 -m pip --no-cache-dir install --upgrade"
ENV GIT_CLONE="git clone --depth 10"

# ==================================================================
# Tools
# ------------------------------------------------------------------

RUN apt-get update && \
    $APT_INSTALL \
    sudo \
    build-essential \
    ca-certificates \
    wget \
    curl \
    git \
    zip \
    unzip \
    nano \
    ffmpeg \
    software-properties-common \
    gnupg \
    python3 \
    python3-pip \
    python3-dev

# ==================================================================
# Git-lfs
# ------------------------------------------------------------------

RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash && \
    $APT_INSTALL git-lfs


# Add symlink so python and python3 commands use same python3.9 executable
RUN ln -s /usr/bin/python3 /usr/local/bin/python    

# ==================================================================
# Installing CUDA packages (CUDA Toolkit 12.0 and CUDNN 8.9.7)
# ------------------------------------------------------------------
RUN wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin && \
    mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600 && \
    wget https://developer.download.nvidia.com/compute/cuda/12.0.0/local_installers/cuda-repo-ubuntu2204-12-0-local_12.0.0-525.60.13-1_amd64.deb && \
    dpkg -i cuda-repo-ubuntu2204-12-0-local_12.0.0-525.60.13-1_amd64.deb && \
    cp /var/cuda-repo-ubuntu2204-12-0-local/cuda-*-keyring.gpg /usr/share/keyrings/ && \
    apt-get update && \
    $APT_INSTALL cuda && \  
    rm cuda-repo-ubuntu2204-12-0-local_12.0.0-525.60.13-1_amd64.deb

# Installing CUDNN
RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub && \
    add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/ /" && \
    apt-get update && \
    $APT_INSTALL libcudnn8=8.9.7.29-1+cuda12.2  \
    libcudnn8-dev=8.9.7.29-1+cuda12.2


ENV PATH=$PATH:/usr/local/cuda/bin
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH


# ==================================================================
# PyTorch
# ------------------------------------------------------------------

# Based on https://pytorch.org/get-started/locally/

RUN $PIP_INSTALL torch==2.1.2 torchvision==0.16.2 torchaudio==2.1.2 --index-url https://download.pytorch.org/whl/cu118


RUN $PIP_INSTALL jupyterlab

# Install requirements.txt from the project
COPY requirements.txt /tmp/requirements.txt
RUN $PIP_INSTALL -r /tmp/requirements.txt
RUN rm /tmp/requirements.txt

# ==================================================================
# Startup
# ------------------------------------------------------------------

EXPOSE 8888 6006

CMD jupyter lab --allow-root --ip=0.0.0.0 --no-browser --ServerApp.trust_xheaders=True --ServerApp.disable_check_xsrf=False --ServerApp.allow_remote_access=True --ServerApp.allow_origin='*' --ServerApp.allow_credentials=True