Skip to content

Commit e985a3d

Browse files
committed
[UPDATE] Remove conda; Use UV! Torch is also removed
1 parent 13cc213 commit e985a3d

9 files changed

Lines changed: 132 additions & 93 deletions

File tree

.github/workflows/cd-docker-build-push.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ jobs:
1515
"Dockerfile.cuda",
1616
"Dockerfile.cpu"
1717
]
18-
install_torch: [
19-
true,
20-
false
21-
]
2218

2319
steps:
2420
- name: Free Disk Space (Ubuntu)
@@ -45,8 +41,6 @@ jobs:
4541
password: ${{ secrets.DOCKERHUB_TOKEN }}
4642

4743
- name: Build Docker image
48-
env:
49-
INSTALL_TORCH: ${{ matrix.install_torch }}
5044
run: |
5145
IMAGE_NAME=$(bash ./scripts/build.sh "${{ matrix.dockerfile }}")
5246
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV

Dockerfile.cpu

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,23 @@ ENV LANG=en_US.UTF-8
1010
ARG INSTALL_TORCH
1111
ARG LLVM_VERSION
1212
ARG IMAGE_VERSION
13-
ARG TORCH_VERSION
13+
ARG IMAGE_NAME
1414

1515
LABEL maintainer="JamesNULLiu jamesnulliu@gmail.com"
1616
LABEL version=${IMAGE_VERSION}
1717

18+
ENV IMAGE_NAME=${IMAGE_NAME}
1819
ENV VCPKG_ROOT=/opt/vcpkg
1920
ENV VCPKG_HOME=/opt/vcpkg
20-
ENV CONDA_HOME=/opt/miniconda3
21+
ENV UV_HOME=/opt/uv
2122
ENV ENV_SETUP_FILE=/etc/local/env_setup.sh
2223

2324
SHELL ["/bin/bash", "-c"]
2425

2526
# Some basic tools
2627
RUN apt-get update && apt-get upgrade -y && \
2728
apt-get install -y \
28-
apt-utils lsb-release software-properties-common gnupg git \
29+
apt-utils lsb-release software-properties-common gnupg git acl sed\
2930
vim-gtk3 wget p7zip-full ninja-build curl jq pkg-config ssh \
3031
build-essential gdb htop tmux ttf-mscorefonts-installer kmod \
3132
libssl-dev && \
@@ -65,35 +66,17 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
6566
# Config files
6667
COPY data/vimrc /etc/vim/vimrc
6768
COPY data/env_setup.sh ${ENV_SETUP_FILE}
68-
# [TODO] The config files should not only be copied only to /root, but also to
69-
# /etc/skel, so that the new user can also use them. But in singularity,
70-
# /etc/skel has no effect, so I will decide what to do later.
7169
COPY data/.inputrc data/.bashrc data/.tmux.conf /root/
7270
COPY data/.inputrc data/.bashrc data/.tmux.conf /etc/skel/
71+
COPY data/create-shared-dir /usr/local/bin/
7372

74-
# Install Miniconda3 and conda env
75-
# [TODO] Conda now uses python=3.13 in default. However, some packages (i.e.,
76-
# vllm) only support python<=3.12. That's why I install python=3.12
77-
# mannually here. Maybe some days later I will remove this command.
78-
RUN wget -O /tmp/miniconda3.sh \
79-
https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
80-
mkdir -p ${CONDA_HOME} && \
81-
bash /tmp/miniconda3.sh -b -u -p ${CONDA_HOME} && \
82-
${CONDA_HOME}/bin/conda tos accept && \
83-
\. ${CONDA_HOME}/bin/activate && \
84-
conda upgrade libstdcxx-ng -c conda-forge -y && \
85-
conda install -y python=3.12 && \
86-
pip3 install nvitop --no-cache-dir && \
87-
if [[ "${INSTALL_TORCH}" == "true" ]]; then \
88-
pip3 install torch==${TORCH_VERSION} torchvision torchaudio \
89-
--index-url https://download.pytorch.org/whl/cpu \
90-
--no-cache-dir \
91-
; fi
73+
# Install uv
74+
RUN curl -LsSf https://astral.sh/uv/install.sh | \
75+
env UV_INSTALL_DIR="${UV_HOME}" UV_NO_MODIFY_PATH=1 sh
9276

9377
# Some final steps
9478
RUN apt-get update && apt-get upgrade -y && apt-get autoremove -y && \
9579
apt-get clean && rm -rf /var/lib/apt/lists/* && \
96-
conda clean --all -y && pip cache purge && \
9780
git config --system --unset-all user.name || true && \
9881
git config --system --unset-all user.email || true && \
9982
git config --global --unset-all user.name || true && \

Dockerfile.cuda

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,28 @@ ARG DEBIAN_FRONTEND=noninteractive
77
ENV LANGUAGE=en_US.UTF-8
88
ENV LANG=en_US.UTF-8
99

10-
ARG INSTALL_TORCH
1110
ARG LLVM_VERSION
1211
ARG IMAGE_VERSION
13-
ARG TORCH_VERSION
12+
ARG IMAGE_NAME
1413

1514
LABEL maintainer="JamesNULLiu jamesnulliu@gmail.com"
1615
LABEL version=${IMAGE_VERSION}
1716

17+
ENV IMAGE_NAME=${IMAGE_NAME}
1818
ENV CUDA_HOME=/usr/local/cuda
1919
ENV VCPKG_ROOT=/opt/vcpkg
2020
ENV VCPKG_HOME=/opt/vcpkg
21-
ENV CONDA_HOME=/opt/miniconda3
21+
ENV UV_HOME=/opt/uv
2222
ENV ENV_SETUP_FILE=/etc/local/env_setup.sh
2323

2424
SHELL ["/bin/bash", "-c"]
2525

2626
# Some basic tools
2727
RUN apt-get update && apt-get upgrade -y && \
2828
apt-get install -y \
29-
apt-utils lsb-release software-properties-common gnupg git \
29+
apt-utils lsb-release software-properties-common gnupg git acl sed \
3030
vim-gtk3 wget p7zip-full ninja-build curl jq pkg-config ssh \
31-
build-essential gdb htop tmux ttf-mscorefonts-installer kmod \
31+
build-essential gdb htop tmux ttf-mscorefonts-installer kmod \
3232
libssl-dev && \
3333
fc-cache -f -v
3434

@@ -66,36 +66,17 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
6666
# Config files
6767
COPY data/vimrc /etc/vim/vimrc
6868
COPY data/env_setup.sh ${ENV_SETUP_FILE}
69-
# [TODO] The config files should not only be copied only to /root, but also to
70-
# /etc/skel, so that the new user can also use them. But in singularity,
71-
# /etc/skel has no effect, so I will decide what to do later.
7269
COPY data/.inputrc data/.bashrc data/.tmux.conf /root/
7370
COPY data/.inputrc data/.bashrc data/.tmux.conf /etc/skel/
71+
COPY data/create-shared-dir /usr/local/bin/
7472

75-
# Install Miniconda3 and conda env
76-
# [TODO] Conda now uses python=3.13 in default. However, some packages (i.e.,
77-
# vllm) only support python<=3.12. That's why I install python=3.12
78-
# mannually here. Maybe some days later I will remove this command.
79-
RUN wget -O /tmp/miniconda3.sh \
80-
https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
81-
mkdir -p ${CONDA_HOME} && \
82-
bash /tmp/miniconda3.sh -b -u -p ${CONDA_HOME} && \
83-
${CONDA_HOME}/bin/conda tos accept && \
84-
\. ${CONDA_HOME}/bin/activate && \
85-
conda upgrade libstdcxx-ng -c conda-forge -y && \
86-
conda install -y python=3.12 && \
87-
pip3 install nvitop --no-cache-dir && \
88-
if [[ "${INSTALL_TORCH}" == "true" ]]; then \
89-
TORCH_CU_VER=$(echo $CUDA_VERSION | cut -d'.' -f1,2 | tr -d '.') && \
90-
pip3 install torch==${TORCH_VERSION} torchvision torchaudio \
91-
--index-url "https://download.pytorch.org/whl/cu${TORCH_CU_VER}" \
92-
--no-cache-dir \
93-
; fi
73+
# Install uv
74+
RUN curl -LsSf https://astral.sh/uv/install.sh | \
75+
env UV_INSTALL_DIR="${UV_HOME}" UV_NO_MODIFY_PATH=1 sh
9476

9577
# Some final steps
9678
RUN apt-get update && apt-get upgrade -y && apt-get autoremove -y && \
9779
apt-get clean && rm -rf /var/lib/apt/lists/* && \
98-
conda clean --all -y && pip cache purge && \
9980
git config --system --unset-all user.name || true && \
10081
git config --system --unset-all user.email || true && \
10182
git config --global --unset-all user.name || true && \

data/create-shared-dir

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# ==============================================================================
6+
# Script: create-shared-dir
7+
# Description: Configures one or more directories to be shared with a specific group.
8+
#
9+
# It performs the following actions on each target directory:
10+
# 1. Creates the directory if it doesn't exist.
11+
# 2. Recursively sets the group ownership.
12+
# 3. Sets permissions (group: rwx, others: none).
13+
# 4. Sets the 'setgid' bit on subdirectories to enforce group inheritance.
14+
# 5. Uses Access Control Lists (ACLs) to enforce permissions for new items.
15+
#
16+
# Usage:
17+
# sudo create-shared-dir <shared_group> <dir1> [<dir2> ...]
18+
#
19+
# Example:
20+
# sudo create-shared-dir developers /srv/data /home/shared/project
21+
#
22+
# ==============================================================================
23+
24+
# --- Argument Parsing ---
25+
SHARED_GROUP="$1"
26+
shift # Shift arguments so $@ contains only the directories
27+
TARGET_DIRS=("$@")
28+
29+
# --- Input Validation ---
30+
if [ ${#TARGET_DIRS[@]} -eq 0 ] || [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
31+
echo "Usage: $0 <shared_group> <dir1> [<dir2> ...]"
32+
echo "Example: $0 developers /var/www/project_a"
33+
exit 1
34+
fi
35+
36+
# --- Pre-flight Checks ---
37+
# 1. Check for root privileges.
38+
if [[ $EUID -ne 0 ]]; then
39+
echo "Error: This script must be run as root (or with sudo)." >&2
40+
exit 1
41+
fi
42+
43+
# 2. Check if the specified group exists.
44+
if ! getent group "$SHARED_GROUP" > /dev/null; then
45+
echo "Error: Group '$SHARED_GROUP' does not exist." >&2
46+
exit 1
47+
fi
48+
49+
# --- Main Logic ---
50+
echo "Configuring shared directories for group '$SHARED_GROUP'..."
51+
52+
for target_dir in "${TARGET_DIRS[@]}"; do
53+
echo "--> Processing: $target_dir"
54+
mkdir -p "$target_dir"
55+
chgrp -R "$SHARED_GROUP" "$target_dir"
56+
chmod -R g=rwX,o-rwx "$target_dir"
57+
find "$target_dir" -type d -exec chmod g+s {} +
58+
setfacl -R -m "g:$SHARED_GROUP:rwX" "$target_dir"
59+
setfacl -R -d -m "g:$SHARED_GROUP:rwX" "$target_dir"
60+
done
61+
62+
echo "Configuration complete."
63+
exit 0

data/env_setup.sh

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
1-
echo "[ENV-SETUP] Setting up environment with: ${ENV_SETUP_FILE}"
1+
set -e
2+
3+
sed "s|\${IMAGE_NAME}|${IMAGE_NAME}|g" << 'EOF'
4+
===============================================================================
5+
<-. (`-')_ ,-. _(`-')
6+
\( OO) ) <-. / / ( (OO ).-> <-.
7+
<-.--. ,--./ ,--/ ,--. ) / / \ .'_ ,--. )
8+
(`-'| ,| | \ | | | (`-') / / '`'-..__) | (`-')
9+
(OO |(_| | . '| |) | |OO ) / / | | ' | | |OO )
10+
,--. | | | |\ | (| '__ | / / | | / : (| '__ |
11+
| '-' / | | \ | | |' / / | '-' / | |'
12+
`-----' `--' `--' `-----' `-' `------' `-----'
13+
-------------------------------------------------------------------------------
14+
Image Name: ${IMAGE_NAME}
15+
Creator: jamesnulliu <jamesnulliu@gmail.com>
16+
License: MIT
17+
===============================================================================
18+
EOF
19+
20+
echo "[ENV-SETUP] Sourcing \${ENV_SETUP_FILE}: ${ENV_SETUP_FILE}"
221

322
# @brief Add `$1` into environment variable `$2` if it is not already there.
423
# @example > env_load PATH /usr/local/bin
@@ -25,31 +44,6 @@ env_unload() {
2544
export $var_name=$(IFS=:; echo "${new_paths[*]}")
2645
}
2746

28-
if [ -d "${CONDA_HOME:-}" ]; then
29-
if [[ $- == *i* ]]; then
30-
# Initialize conda in interactive mode
31-
__conda_setup="$('${CONDA_HOME}/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
32-
if [ $? -eq 0 ]; then
33-
eval "$__conda_setup"
34-
else
35-
if [ -f "${CONDA_HOME}/etc/profile.d/conda.sh" ]; then
36-
. "${CONDA_HOME}/etc/profile.d/conda.sh"
37-
else
38-
env_load PATH "${CONDA_HOME}/bin"
39-
fi
40-
fi
41-
unset __conda_setup
42-
echo "[ENV-SETUP] Conda initialized in interactive mode from $CONDA_HOME"
43-
else
44-
# Initialize conda in non-interactive mode
45-
# Note that you may have to use `conda run` to use conda environments
46-
. "${CONDA_HOME}/etc/profile.d/conda.sh"
47-
echo "[ENV-SETUP] Conda initialized in non-interactive mode from $CONDA_HOME."
48-
fi
49-
else
50-
unset CONDA_HOME
51-
fi
52-
5347
if [ -d "${CUDA_HOME:-}" ]; then
5448
alias LOAD_CUDA="env_load PATH $CUDA_HOME/bin && \
5549
env_load LD_LIBRARY_PATH $CUDA_HOME/lib64"
@@ -71,4 +65,18 @@ if [ -d "${VCPKG_HOME:-}" ]; then
7165
echo "[ENV-SETUP] VCPKG initialized from $VCPKG_HOME"
7266
else
7367
unset VCPKG_HOME
68+
fi
69+
70+
if [ -d "${UV_HOME:-}" ]; then
71+
alias LOAD_UV="env_load PATH $UV_HOME"
72+
alias UNLOAD_UV="env_unload PATH $UV_HOME"
73+
env_load PATH "$UV_HOME"
74+
echo "[ENV-SETUP] UV initialized from $UV_HOME"
75+
echo "|- Note: For managing shared UV cache directory:"
76+
echo "|- 1. Export UV_CACHE_DIR to a target directory. (No need to create it first.)"
77+
echo "|- 2. Run: \`sudo create-shared-dir <group> \${UV_CACHE_DIR}\`"
78+
echo "|- 3. For all users in <group>, make sure UV_CACHE_DIR is set properly."
79+
echo "|- You can add it to \${ENV_SETUP_FILE} for convenience."
80+
else
81+
unset UV_HOME
7482
fi

scripts/build.sh

100644100755
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/bin/bash
2+
13
set -e
24

35
DOCKER_FILE=$1
@@ -10,20 +12,14 @@ elif [[ "${DOCKER_FILE}" == *.cuda ]]; then
1012
IMAGE_TAG="${IMAGE_TAG}-cuda${CUDA_VERSION}"
1113
fi
1214

13-
if [[ "${INSTALL_TORCH}" == "true" ]]; then
14-
IMAGE_TAG="${IMAGE_TAG}-torch${TORCH_VERSION}"
15-
fi
16-
1715
IMAGE_NAME=jamesnulliu/deeplearning:${IMAGE_TAG}
1816

1917
docker build \
2018
-f $DOCKER_FILE \
21-
--build-arg INSTALL_TORCH=$INSTALL_TORCH \
2219
--build-arg IMAGE_VERSION=$IMAGE_VERSION \
23-
--build-arg TORCH_VERSION=$TORCH_VERSION \
20+
--build-arg IMAGE_NAME=$IMAGE_NAME \
2421
--build-arg CUDA_VERSION=$CUDA_VERSION \
2522
--build-arg UBUNTU_VERSION=$UBUNTU_VERSION \
26-
--build-arg CUDNN_VERSION=$CUDNN_VERSION \
2723
--build-arg LLVM_VERSION=$LLVM_VERSION \
2824
-t $IMAGE_NAME \
2925
.

scripts/exec.sh

100644100755
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/bin/bash
2+
13
CONTAINER_NAME=$1
24

35
if [ ! $CONTAINER_NAME ]; then

scripts/image-configs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
IMAGE_VERSION=2.3.0
1+
IMAGE_VERSION=2.4.0
22
TORCH_VERSION=2.7.1
33
CUDA_VERSION=12.8.0
44
UBUNTU_VERSION=24.04

scripts/run.sh

100644100755
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/bin/bash
2+
13
set -e
24

35
IMAGE_NAME=$1
@@ -12,6 +14,7 @@ if [ ! $CONTAINER_NAME ]; then
1214
CONTAINER_NAME=tmp
1315
fi
1416

17+
if [[ "$IMAGE_NAME" == *"cuda"* ]]; then
1518
docker run -td \
1619
--name $CONTAINER_NAME \
1720
--gpus all \
@@ -20,6 +23,15 @@ docker run -td \
2023
--hostname $CONTAINER_NAME \
2124
-v $HOME/Projects:/root/Projects \
2225
$IMAGE_NAME
26+
else
27+
docker run -td \
28+
--name $CONTAINER_NAME \
29+
--network=host \
30+
--shm-size=16G \
31+
--hostname $CONTAINER_NAME \
32+
-v $HOME/Projects:/root/Projects \
33+
$IMAGE_NAME
34+
fi
2335

2436
docker cp $HOME/.ssh $CONTAINER_NAME:/root/
2537
docker start $CONTAINER_NAME

0 commit comments

Comments
 (0)