-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·63 lines (54 loc) · 2.81 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
#!/bin/bash -f
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
# Libraries download
cd "$SCRIPT_DIR" || exit
if [ ! -d libs ]; then
mkdir libs
cd libs/ || exit
# Download cereal library
git clone -b v1.3.2 --single-branch --depth 1 https://github.com/USCiLab/cereal.git
export CEREAL_HOME="$SCRIPT_DIR/libs/cereal/include"
# Try to guess OS and ARCH for binary libtorch
if [ ! -d torch ]; then
ARCH=$(uname -m)
OS=$(uname -s)
[ "$OS" == "Darwin" ] && TORCHURL="https://files.pythonhosted.org/packages/4d/80/760f3edcf0179c3111fae496b97ee3fa9171116b4bccae6e073efe928e72/torch-2.0.0-cp39-none-macosx_11_0_$ARCH.whl"
[ "$OS" == "Linux" ] && [ "$ARCH" == "x86_64" ] && TORCHURL="https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.0.0%2Bcpu.zip"
[ "$OS" == "Linux" ] && [ "$ARCH" == "aarch64" ] && TORCHURL="https://files.pythonhosted.org/packages/36/60/aa7bf18070611e7b019886d34516337ce6a2fe9da60745bc90b448642a10/torch-2.0.0-cp39-cp39-manylinux2014_aarch64.whl"
[ "$OS" == "Linux" ] && [ "$ARCH" == "riscv64" ] && TORCHURL="https://gitlab.di.unito.it/alpha/riscv/torch/-/package_files/17/download"
[ "$TORCHURL" == "" ] && echo "Could not determine the libtorch binary for this system. Please manualy install libtorch to $SCRIPT_DIR/libs/torch" && exit 1
curl "$TORCHURL" -o torch.whl
unzip torch.whl "torch/*" "libtorch/*" >/dev/null
mv libtorch torch &>/dev/null
rm -f torch.whl
fi
# Download fastflow and build the dff_run utility
git clone -b DistributedFF --single-branch --depth 1 https://github.com/fastflow/fastflow.git
cd fastflow/ff/distributed/loader || exit
make
fi
# Environment variables setting
export TORCH_HOME="$SCRIPT_DIR/libs/torch"
export CEREAL_HOME="$SCRIPT_DIR/libs/cereal/include"
export FF_HOME="$SCRIPT_DIR/libs/fastflow"
export PATH="$FF_HOME/ff/distributed/loader:$PATH"
# MNIST dataset download
cd "$SCRIPT_DIR" || exit
if [ ! -d data ]; then
wget https://datacloud.di.unito.it/index.php/s/6qgZGtMMeqm3Ytq/download
unzip download
rm -rf download __MACOSX
cd data/ || exit
[ ! -e train-images-idx3-ubyte ] && curl -o - http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz | gunzip >train-images-idx3-ubyte
[ ! -e train-labels-idx1-ubyte ] && curl -o - http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz | gunzip >train-labels-idx1-ubyte
[ ! -e t10k-images-idx3-ubyte ] && curl -o - http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz | gunzip >t10k-images-idx3-ubyte
[ ! -e t10k-labels-idx1-ubyte ] && curl -o - http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz | gunzip >t10k-labels-idx1-ubyte
fi
# Code building
cd "$SCRIPT_DIR" || exit
[ -d build ] && rm -rf build
mkdir build
cd build/ || exit
cmake ../
make -j "$(getconf _NPROCESSORS_ONLN)"
cd "$SCRIPT_DIR" || exit