@@ -2,6 +2,7 @@ ARG CUDA_VERSION
22ARG UBUNTU_VERSION
33
44FROM nvidia/cuda:${CUDA_VERSION}-cudnn-devel-ubuntu${UBUNTU_VERSION}
5+ CMD ["bash"]
56
67ARG DEBIAN_FRONTEND=noninteractive
78ENV LANGUAGE=en_US.UTF-8
@@ -15,6 +16,12 @@ ARG TORCH_VERSION
1516LABEL maintainer="JamesNULLiu jamesnulliu@gmail.com"
1617LABEL version=${IMAGE_VERSION}
1718
19+ ENV CUDA_HOME=/usr/local/cuda
20+ ENV VCPKG_ROOT=/opt/vcpkg
21+ ENV VCPKG_HOME=/opt/vcpkg
22+ ENV CONDA_HOME=/opt/miniconda3
23+ ENV ENV_SETUP_FILE=/etc/local/env_setup.sh
24+
1825SHELL ["/bin/bash", "-c"]
1926
2027# Some basic tools
@@ -27,8 +34,8 @@ RUN apt-get update && apt-get upgrade -y && \
2734 fc-cache -f -v
2835
2936# Vcpkg
30- RUN cd /usr/local && git clone https://github.com/microsoft/vcpkg.git && \
31- cd vcpkg && ./bootstrap-vcpkg.sh
37+ RUN git clone https://github.com/microsoft/vcpkg.git ${VCPKG_HOME} && \
38+ cd ${VCPKG_HOME} && ./bootstrap-vcpkg.sh
3239
3340# CMake
3441RUN wget -O /tmp/kitware-archive.sh \
@@ -37,19 +44,16 @@ RUN wget -O /tmp/kitware-archive.sh \
3744 apt-get update && apt-get install -y cmake
3845
3946# LLVM
40- RUN wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | \
41- tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc && \
42- echo "deb http://apt.llvm.org/noble/ llvm-toolchain-noble main" | \
43- tee /etc/apt/sources.list.d/llvm.list && \
44- echo "deb-src http://apt.llvm.org/noble/ llvm-toolchain-noble main" | \
45- tee -a /etc/apt/sources.list.d/llvm.list && \
47+ RUN wget -O /tmp/llvm.sh https://apt.llvm.org/llvm.sh && \
48+ chmod +x /tmp/llvm.sh && \
49+ /tmp/llvm.sh ${LLVM_VERSION} && \
4650 apt-get update && apt-get install -y \
47- clang-${LLVM_VERSION} lldb-${LLVM_VERSION} \
48- clang-tools-${LLVM_VERSION} libclang-${LLVM_VERSION}-dev \
49- clang-format-${LLVM_VERSION} python3-clang-${LLVM_VERSION} \
50- clangd-${LLVM_VERSION} clang-tidy-${LLVM_VERSION} \
51- lldb-${LLVM_VERSION} libc++-${LLVM_VERSION}-dev \
52- libc++abi-${LLVM_VERSION}-dev libomp-${LLVM_VERSION}-dev && \
51+ clang-${LLVM_VERSION} lldb-${LLVM_VERSION} \
52+ clang-tools-${LLVM_VERSION} libclang-${LLVM_VERSION}-dev \
53+ clang-format-${LLVM_VERSION} python3-clang-${LLVM_VERSION} \
54+ clangd-${LLVM_VERSION} clang-tidy-${LLVM_VERSION} \
55+ lldb-${LLVM_VERSION} libc++-${LLVM_VERSION}-dev \
56+ libc++abi-${LLVM_VERSION}-dev libomp-${LLVM_VERSION}-dev && \
5357 ln -s /usr/bin/clang-${LLVM_VERSION} /usr/bin/clang && \
5458 ln -s /usr/bin/clang++-${LLVM_VERSION} /usr/bin/clang++ && \
5559 ln -s /usr/bin/clangd-${LLVM_VERSION} /usr/bin/clangd && \
@@ -61,33 +65,39 @@ RUN wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | \
6165RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
6266
6367# Config files
64- COPY data/.vimrc data/.inputrc data/.bashrc data/.setup_env.sh data/.tmux.conf \
65- /root/
68+ COPY data/vimrc /etc/vim/vimrc
69+ COPY data/env_setup.sh ${ENV_SETUP_FILE}
70+ # [TODO] The config files should not only be copied only to /root, but also to
71+ # /etc/skel, so that the new user can also use them. But in singularity,
72+ # /etc/skel has no effect, so I will decide what to do later.
73+ COPY data/.inputrc data/.bashrc data/.tmux.conf /root/
74+ COPY data/.inputrc data/.bashrc data/.tmux.conf /etc/skel/
6675
6776# Install Miniconda3 and conda env
6877# [TODO] Conda now uses python=3.13 in default. However, some packages (i.e.,
6978# vllm) only support python<=3.12. That's why I install python=3.12
7079# mannually here. Maybe some days later I will remove this command.
7180RUN wget -O /tmp/miniconda3.sh \
7281 https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
73- mkdir -p /root/miniconda3 && \
74- bash /tmp/miniconda3.sh -b -u -p /root/miniconda3 && \
75- \. /root/miniconda3/bin/activate && \
82+ mkdir -p ${CONDA_HOME} && \
83+ bash /tmp/miniconda3.sh -b -u -p ${CONDA_HOME} && \
84+ ${CONDA_HOME}/bin/conda tos accept && \
85+ \. ${CONDA_HOME}/bin/activate && \
7686 conda upgrade libstdcxx-ng -c conda-forge -y && \
7787 conda install -y python=3.12 && \
7888 pip3 install nvitop --no-cache-dir && \
7989 if [[ "${INSTALL_TORCH}" == "true" ]]; then \
80- TORCH_CU_VER=$(echo $CUDA_VERSION | cut -d'.' -f1,2 | tr -d '.') && \
81- pip3 install torch==${TORCH_VERSION} torchvision torchaudio \
82- --index-url "https://download.pytorch.org/whl/cu${TORCH_CU_VER}" \
83- --no-cache-dir \
90+ TORCH_CU_VER=$(echo $CUDA_VERSION | cut -d'.' -f1,2 | tr -d '.') && \
91+ pip3 install torch==${TORCH_VERSION} torchvision torchaudio \
92+ --index-url "https://download.pytorch.org/whl/cu${TORCH_CU_VER}" \
93+ --no-cache-dir \
8494 ; fi
8595
8696# Some final steps
8797RUN apt-get update && apt-get upgrade -y && apt-get autoremove -y && \
8898 apt-get clean && rm -rf /var/lib/apt/lists/* && \
8999 conda clean --all -y && pip cache purge && \
90- git config --system --unset-all user.name || true && \
100+ git config --system --unset-all user.name || true && \
91101 git config --system --unset-all user.email || true && \
92- git config --global --unset-all user.name || true && \
93- git config --global --unset-all user.email || true
102+ git config --global --unset-all user.name || true && \
103+ git config --global --unset-all user.email || true
0 commit comments