Skip to content

Commit 17344e1

Browse files
committed
Move some settings from .bashrc to .setup_env.sh
1 parent 345e26c commit 17344e1

5 files changed

Lines changed: 60 additions & 56 deletions

File tree

Dockerfile.cpu

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ RUN wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | \
6161
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
6262

6363
# Config files
64-
COPY data/.vimrc data/.inputrc data/.bashrc data/.tmux.conf /root/
64+
COPY data/.vimrc data/.inputrc data/.bashrc data/.setup_env.sh data/.tmux.conf \
65+
/root/
6566

6667
# Install Miniconda3 and conda env
6768
# [TODO] Conda now uses python=3.13 in default. However, some packages (i.e.,

Dockerfile.cuda

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ RUN wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | \
6161
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
6262

6363
# Config files
64-
COPY data/.vimrc data/.inputrc data/.bashrc data/.tmux.conf /root/
64+
COPY data/.vimrc data/.inputrc data/.bashrc data/.setup_env.sh data/.tmux.conf \
65+
/root/
6566

6667
# Install Miniconda3 and conda env
6768
# [TODO] Conda now uses python=3.13 in default. However, some packages (i.e.,

data/.bashrc

Lines changed: 2 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -102,56 +102,5 @@ fi
102102
# . /etc/bash_completion
103103
#fi
104104

105-
# >>> conda initialize >>>
106-
# !! Contents within this block are managed by 'conda init' !!
107-
__conda_setup="$('/root/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
108-
if [ $? -eq 0 ]; then
109-
eval "$__conda_setup"
110-
else
111-
if [ -f "/root/miniconda3/etc/profile.d/conda.sh" ]; then
112-
. "/root/miniconda3/etc/profile.d/conda.sh"
113-
else
114-
export PATH="/root/miniconda3/bin:$PATH"
115-
fi
116-
fi
117-
unset __conda_setup
118-
# <<< conda initialize <<<
119-
120-
# @brief Add `$1` into environment variable `$2` if it is not already there.
121-
# @example > env_load PATH /usr/local/bin
122-
env_load() {
123-
local env_var=$1
124-
local path=$2
125-
if [[ ":${!env_var}:" != *":$path:"* ]]; then
126-
export $env_var="${!env_var}:$path"
127-
fi
128-
}
129-
130-
# @brief Remove `$1` from environment variable `$2` if it is there.
131-
# @example > env_unload PATH /usr/local/bin
132-
env_unload() {
133-
local env_var=$1
134-
local path=$2
135-
local paths_array=(${!env_var//:/ })
136-
local new_paths=()
137-
for item in "${paths_array[@]}"; do
138-
if [[ "$item" != "$path" ]]; then
139-
new_paths+=("$item")
140-
fi
141-
done
142-
export $env_var=$(IFS=:; echo "${new_paths[*]}")
143-
}
144-
145-
export CUDA_HOME="/usr/local/cuda"
146-
alias LOAD_CUDA="env_load PATH $CUDA_HOME/bin && env_load LD_LIBRARY_PATH $CUDA_HOME/lib64"
147-
alias UNLOAD_CUDA="env_unload PATH $CUDA_HOME/bin && env_unload LD_LIBRARY_PATH $CUDA_HOME/lib64"
148-
# Load CUDA by default
149-
LOAD_CUDA
150-
151-
export VCPKG_HOME="/usr/local/vcpkg"
152-
export VCPKG_ROOT=$VCPKG_HOME
153-
alias LOAD_VCPKG="env_load PATH $VCPKG_HOME"
154-
alias UNLOAD_VCPKG="env_unload PATH $VCPKG_HOME"
155-
alias VCPKG_UPDATE="pushd $VCPKG_HOME && git pull && popd"
156-
# Load vcpkg by default
157-
LOAD_VCPKG
105+
# Load all environment settings
106+
source ~/.setup_env.sh

data/.setup_env.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# @brief Add `$1` into environment variable `$2` if it is not already there.
2+
# @example > env_load PATH /usr/local/bin
3+
env_load() {
4+
local env_var=$1
5+
local path=$2
6+
if [[ ":${!env_var}:" != *":$path:"* ]]; then
7+
export $env_var="${!env_var}:$path"
8+
fi
9+
}
10+
11+
# @brief Remove `$1` from environment variable `$2` if it is there.
12+
# @example > env_unload PATH /usr/local/bin
13+
env_unload() {
14+
local env_var=$1
15+
local path=$2
16+
local paths_array=(${!env_var//:/ })
17+
local new_paths=()
18+
for item in "${paths_array[@]}"; do
19+
if [[ "$item" != "$path" ]]; then
20+
new_paths+=("$item")
21+
fi
22+
done
23+
export $env_var=$(IFS=:; echo "${new_paths[*]}")
24+
}
25+
26+
# >>> conda initialize >>>
27+
# !! Contents within this block are managed by 'conda init' !!
28+
__conda_setup="$('/root/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
29+
if [ $? -eq 0 ]; then
30+
eval "$__conda_setup"
31+
else
32+
if [ -f "/root/miniconda3/etc/profile.d/conda.sh" ]; then
33+
. "/root/miniconda3/etc/profile.d/conda.sh"
34+
else
35+
env_load PATH "/root/miniconda3/bin"
36+
fi
37+
fi
38+
unset __conda_setup
39+
# <<< conda initialize <<<
40+
41+
export CUDA_HOME="/usr/local/cuda"
42+
alias LOAD_CUDA="env_load PATH $CUDA_HOME/bin && env_load LD_LIBRARY_PATH $CUDA_HOME/lib64"
43+
alias UNLOAD_CUDA="env_unload PATH $CUDA_HOME/bin && env_unload LD_LIBRARY_PATH $CUDA_HOME/lib64"
44+
# Load CUDA by default
45+
LOAD_CUDA
46+
47+
export VCPKG_HOME="/usr/local/vcpkg"
48+
export VCPKG_ROOT=$VCPKG_HOME
49+
alias LOAD_VCPKG="env_load PATH $VCPKG_HOME"
50+
alias UNLOAD_VCPKG="env_unload PATH $VCPKG_HOME"
51+
alias VCPKG_UPDATE="pushd $VCPKG_HOME && git pull && popd"
52+
# Load vcpkg by default
53+
LOAD_VCPKG

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.2.3
1+
IMAGE_VERSION=2.2.4
22
TORCH_VERSION=2.7.0
33
CUDA_VERSION=12.8.0
44
UBUNTU_VERSION=24.04

0 commit comments

Comments
 (0)