-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·90 lines (71 loc) · 2.66 KB
/
setup.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
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
#! /bin/bash
# ensure that the script has been sourced rather than just executed
if [[ "${BASH_SOURCE[0]}" = "${0}" ]]; then
echo "Please use 'source' to execute setup.sh!"
exit 1
fi
CURRENTDIR=$(pwd)
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "$DIR"
# First we setup the CUDA version to use 10.1
INSTALL_FOLDER="/usr/local" # the location to look for CUDA installations at
TARGET_VERSION="10.1" # the target CUDA version to switch to (if provided)
# check whether there is an installation of the requested CUDA version
if [[ ! -d "${INSTALL_FOLDER}/cuda-${TARGET_VERSION}" ]]; then
echo "No installation of CUDA ${TARGET_VERSION} has been found!"
set +e
return
fi
# the path of the installation to use
cuda_path="${INSTALL_FOLDER}/cuda-${TARGET_VERSION}"
# filter out those CUDA entries from the PATH that are not needed anymore
path_elements=(${PATH//:/ })
new_path="${cuda_path}/bin"
for p in "${path_elements[@]}"; do
if [[ ! ${p} =~ ^${INSTALL_FOLDER}/cuda ]]; then
new_path="${new_path}:${p}"
fi
done
# filter out those CUDA entries from the LD_LIBRARY_PATH that are not needed anymore
ld_path_elements=(${LD_LIBRARY_PATH//:/ })
new_ld_path="${cuda_path}/lib64:${cuda_path}/extras/CUPTI/lib64"
for p in "${ld_path_elements[@]}"; do
if [[ ! ${p} =~ ^${INSTALL_FOLDER}/cuda ]]; then
new_ld_path="${new_ld_path}:${p}"
fi
done
# update environment variables
export CUDA_HOME="${cuda_path}"
export CUDA_ROOT="${cuda_path}"
export LD_LIBRARY_PATH="${new_ld_path}"
export PATH="${new_path}"
echo "Switched to CUDA ${TARGET_VERSION}."
if [[ -d ".conda/envs/chipsnet/" ]]; then
source .conda/bin/activate
conda activate chipsnet
else
# Download the latest version of miniconda3
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh --no-check-certificate
# Install miniconda3 in the current directory
bash miniconda.sh -b -p "$DIR/.conda"
rm miniconda.sh
# Activate miniconda and create the chipsnet environment
source .conda/bin/activate
conda update -n base -c defaults conda -y
conda config --add envs_dirs "$DIR/.conda/envs"
conda config --add envs_dirs "$DIR/.conda/envs"
conda env create -f "$DIR/environment.yaml"
# Clean the miniconda install
conda clean --all -y
# Make sure the base environement is not enabled by default
conda config --set auto_activate_base false
conda activate chipsnet
fi
# Go back to the user directory
cd "$CURRENTDIR"
if [[ -f ".comet" ]]; then
while read LINE; do export "$LINE"; done < .comet
fi
export PYTHONPATH=$PYTHONPATH:$(pwd)
echo "Setup complete."
return