forked from jdmulligan/bayesian-inference
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sh
executable file
·52 lines (47 loc) · 1.31 KB
/
init.sh
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
#!/usr/bin/env bash
# On hiccup CPU, we use pyenv -- on hiccup GPU, we will use system python
if ! lspci | grep -i 'nvidia' > /dev/null; then
# Set up pyenv (for python version management)
export PYENV_ROOT="/home/software/users/james/pyenv"
export PYTHON_CONFIGURE_OPTS="--enable-shared"
export PATH="${PATH}:${PYENV_ROOT}/bin"
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
pyenv local 3.9.12
fi
# Get command line option to determine whether we need to install the virtual environment, or just enter it
for i in "$@"; do
case $i in
--install)
INSTALL=TRUE
shift
;;
-*|--*)
echo "Unknown option $i"
exit 1
;;
*)
;;
esac
done
# Install separate venv for GPU and CPU (to allow to work on either machine, using same home directory)
if lspci | grep -i 'nvidia' > /dev/null; then
VENV_DIR=".venv_gpu"
else
VENV_DIR=".venv_cpu"
fi
if [ ! -z ${INSTALL} ]; then
if [ -d $VENV_DIR ]; then
echo
echo "Remove existing virtual environment..."
rm -r $VENV_DIR
fi
echo
echo "Create new virtual environment..."
echo "Using $VENV_DIR"
python -m venv $VENV_DIR
pdm use $VENV_DIR/bin/python
pdm install
fi
# Initialize python virtual environment for package management
source $VENV_DIR/bin/activate