forked from april-tools/e4selflearning
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·61 lines (55 loc) · 1.5 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
#!/bin/sh
device=false
current_dir="$(pwd -P)"
check_requirements() {
case $(uname -s) in
Darwin)
if [ "$(uname -m)" = "arm64" ]; then
printf "macOS (Apple Silicon) system detected.\n"
device="osx-arm64"
else
printf "macOS (Intel) system detected.\n"
export CFLAGS='-stdlib=libc++'
device="osx-64"
fi
;;
Linux)
printf "Linux system detected.\n"
device="linux-64"
;;
*)
printf "Only Linux and macOS are currently supported.\n"
exit 1
;;
esac
}
install_torch() {
printf "\nInstalling PyTorch...\n"
case $device in
osx-arm64)
conda install -c pytorch pytorch torchvision torchaudio -y
;;
osx-64)
conda install -c pytorch pytorch torchvision torchaudio -y
;;
linux-64)
conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia -y
;;
*)
pip install pytorch torchvision torchaudio
;;
esac
}
install_packages() {
printf "\nInstalling other Python packages...\n"
pip install -e .
if [ "$device" = "osx-arm64" ]; then
printf "\nInstall conda-forge version of cvxopt\n"
pip uninstall cvxopt -y
conda install cvxopt -y
fi
}
check_requirements
install_torch
install_packages
printf '\nSetup completed.\n'