forked from matifali/dockerdl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conda.Dockerfile
123 lines (107 loc) · 3.48 KB
/
conda.Dockerfile
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# Build argumnets
ARG CUDA_VER=11.7.1
ARG UBUNTU_VER=22.04
# Download the base image
FROM nvidia/cuda:${CUDA_VER}-cudnn8-runtime-ubuntu${UBUNTU_VER}
# you can check for all available images at https://hub.docker.com/r/nvidia/cuda/tags
# Install as root
USER root
# Shell
SHELL ["/bin/bash", "--login", "-o", "pipefail", "-c"]
# miniconda path
ENV CONDA_DIR /opt/miniconda
# conda path
ENV PATH=${CONDA_DIR}/bin:$PATH
ARG DEBIAN_FRONTEND="noninteractive"
ARG USERNAME=coder
ARG USERID=1000
ARG GROUPID=1000
# Install dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
bash \
bash-completion \
ca-certificates \
curl \
git \
htop \
nano \
openssh-client \
sudo \
tmux \
unzip \
vim \
wget \
zip && \
apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install Microsoft's code-server
RUN wget -O- https://aka.ms/install-vscode-server/setup.sh | sh
# Expose port 8000 for code-server
EXPOSE 8000
# Install miniconda
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh && \
/bin/bash miniconda.sh -b -p ${CONDA_DIR} && \
rm -rf miniconda.sh && \
# Enable conda autocomplete
sudo wget --quiet https://github.com/tartansandal/conda-bash-completion/raw/master/conda -P /etc/bash_completion.d/
# Add a user `${USERNAME}` so that you're not developing as the `root` user
RUN groupadd -g ${GROUPID} ${USERNAME} && \
useradd ${USERNAME} \
--create-home \
--uid ${USERID} \
--gid ${GROUPID} \
--shell=/bin/bash && \
echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" >>/etc/sudoers.d/nopasswd && \
# Allow running conda as the new user
groupadd conda && chgrp -R conda ${CONDA_DIR} && chmod 755 -R ${CONDA_DIR} && adduser ${USERNAME} conda && \
echo ". $CONDA_DIR/etc/profile.d/conda.sh" >>/home/${USERNAME}/.profile && \
# Install mamba
conda install mamba -n base -c conda-forge && \
# clean up
conda clean --all --yes
# Python version
ARG PYTHON_VER=3.10
# Change to your user
USER ${USERNAME}
# Chnage Workdir
WORKDIR /home/${USERNAME}
# Initilize shell for conda/mamba
RUN conda init bash && \
mamba init bash && \
source /home/${USERNAME}/.bashrc
# Create deep-learning environment
RUN mamba create --name DL --channel conda-forge python=${PYTHON_VER} --yes && \
mamba clean --all --yes && \
# Make new shells activate the DL environment:
echo "# Make new shells activate the DL environment" >>/home/${USERNAME}/.bashrc && \
echo "conda activate DL" >>/home/${USERNAME}/.bashrc
# Tensorflow Package version passed as build argument e.g. --build-arg TF_VERSION=2.9.2
# A blank value will install the latest version
ARG TF_VERSION=
# Install packages inside the new environment
RUN conda activate DL && \
pip install --upgrade --no-cache-dir pip && \
pip install --upgrade --no-cache-dir torch torchvision torchaudio torchtext pytorch-lightning && \
pip install --upgrade --no-cache-dir \
ipywidgets \
jupyterlab \
matplotlib \
nltk \
notebook \
numpy \
pandas \
Pillow \
plotly \
PyYAML \
scipy \
scikit-image \
scikit-learn \
sympy \
seaborn \
tensorflow${TF_VERSION:+==${TF_VERSION}} \
tqdm && \
pip cache purge && \
# Set path of python packages
echo "# Set path of python packages" >>/home/${USERNAME}/.bashrc && \
echo 'export PATH=$HOME/.local/bin:$PATH' >>/home/${USERNAME}/.bashrc