-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcuda.Dockerfile
More file actions
146 lines (130 loc) · 4.4 KB
/
cuda.Dockerfile
File metadata and controls
146 lines (130 loc) · 4.4 KB
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# Stage 1: Build neovim
FROM nvidia/cuda:12.4.1-cudnn-devel-ubuntu22.04 AS neovim-builder
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
ca-certificates \
build-essential \
cmake \
gettext \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /root
RUN git clone https://github.com/neovim/neovim \
&& cd neovim \
&& make CMAKE_BUILD_TYPE=RelWithDebInfo \
&& make install \
&& cd .. \
&& rm -rf neovim
# Stage 2: Final image
FROM nvidia/cuda:12.4.1-cudnn-devel-ubuntu22.04
# Set ARGs for versions and reduce repetition
ARG DEBIAN_FRONTEND=noninteractive
ARG PYTHON_VERSION=3.11
ARG USER=root
ARG SHELL=/bin/zsh
# Copy neovim from builder
COPY --from=neovim-builder /usr/local/bin/nvim /usr/local/bin/
COPY --from=neovim-builder /usr/local/share/nvim /usr/local/share/nvim
# Install essential packages in a single layer
RUN apt-get update && apt-get install -y --no-install-recommends \
software-properties-common \
make \
build-essential \
libssl-dev \
zlib1g-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
wget \
tree \
llvm \
libncursesw5-dev \
xz-utils \
tk-dev \
libxml2-dev \
libxmlsec1-dev \
libffi-dev \
liblzma-dev \
&& add-apt-repository ppa:deadsnakes/ppa -y \
&& apt-get update && apt-get install -y --no-install-recommends \
python${PYTHON_VERSION} \
python${PYTHON_VERSION}-dev \
zsh \
nvtop \
btop \
tmux \
git \
curl \
nano \
ca-certificates \
unzip \
fd-find \
nodejs \
npm \
nvidia-utils-535 \
openssh-server \
locales \
&& locale-gen en_US.UTF-8 \
&& update-locale LANG=en_US.UTF-8 \
&& update-alternatives --install /usr/bin/python python /usr/bin/python${PYTHON_VERSION} 100 \
&& rm -rf /var/lib/apt/lists/*
# Add Conda installation and setup
RUN wget -v https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh \
&& bash ~/miniconda.sh -b -p /opt/conda \
&& rm ~/miniconda.sh \
&& /opt/conda/bin/conda init zsh \
&& /opt/conda/bin/conda install python=3.11 -y \
&& /opt/conda/bin/conda config --set auto_activate_base true
# Add Conda to PATH
ENV PATH=/opt/conda/bin:$PATH \
CONDA_DEFAULT_ENV=base
# Set environment variables
ENV LANG=en_US.UTF-8 \
LANGUAGE=en_US:en \
LC_ALL=en_US.UTF-8 \
SHELL=${SHELL}
# Configure SSH
RUN echo 'root:helloworld' | chpasswd \
&& sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config \
&& sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config \
&& mkdir -p /var/run/sshd \
&& mkdir -p /root/.config/clangd
# Setup clangd config
COPY <<EOF /root/.config/clangd/config.yaml
CompileFlags:
Add:
- --cuda-gpu-arch=sm_86
Remove:
- --generate-code=arch=*
- -forward-unknown-to-host-compiler
EOF
# Install pip and Jupyter in a single layer
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python${PYTHON_VERSION} \
&& python -m pip install --no-cache-dir jupyterhub jupyterlab notebook ipywidgets nvitop poetry \
&& npm install -g configurable-http-proxy
# Configure Poetry to create virtual environments in the project directory
RUN poetry config virtualenvs.in-project true
# Setup zsh environment
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" \
&& git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k \
&& git clone --depth 1 https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions \
&& git clone --depth 1 https://github.com/z-shell/F-Sy-H.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/F-Sy-H \
&& git clone --depth 1 https://github.com/zsh-users/zsh-completions.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-completions \
&& git clone --depth 1 https://github.com/zsh-users/zsh-history-substring-search.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-history-substring-search
# Copy configuration files
COPY vim_setup /root/.config/nvim/
COPY dotfiles/.zshrc /root/.zshrc
COPY dotfiles/.p10k.zsh /root/.p10k.zsh
COPY scripts/create-user.sh /start-scripts/
COPY scripts/jupyterhub_config.py /root/
# Set working directory
WORKDIR /root
RUN echo '#!/bin/bash\n\
service ssh start\n\
\n\
# Keep container running\n\
while true; do\n\
sleep 1\n\
done' > /entrypoint.sh \
&& chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["zsh"]