gotch/setup-cpu.sh

36 lines
1.7 KiB
Bash
Raw Permalink Normal View History

2020-07-26 04:20:05 +01:00
#!/bin/bash
2020-10-10 22:45:49 +01:00
# Env
2020-10-27 06:34:12 +00:00
GOTCH_VERSION="${GOTCH_VER:-v0.1.9}"
2020-10-11 13:14:21 +01:00
LIBTORCH_VERSION="${LIBTORCH_VER:-1.5.1}"
2020-10-11 01:27:28 +01:00
GOTCH="$GOPATH/pkg/mod/github.com/sugarme/gotch@$GOTCH_VERSION"
LIBTORCH="$GOPATH/pkg/mod/github.com/sugarme/gotch@$GOTCH_VERSION/libtch/libtorch"
LIBRARY_PATH="$LIBTORCH/lib"
CPATH="$LIBTORCH/lib:$LIBTORCH/include:$LIBTORCH/include/torch/csrc:$LIBTORCH/include/torch/csrc/api/include"
LD_LIBRARY_PATH="$LIBTORCH/lib"
2020-10-10 22:45:49 +01:00
# Precompiled libtorch
2020-10-11 01:27:28 +01:00
sudo rm -rf $LIBTORCH
sudo mkdir -p $LIBTORCH
2020-10-11 13:14:21 +01:00
wget -O /tmp/libtorch-cxx11-abi-shared-with-deps-${LIBTORCH_VERSION}+cpu.zip https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-${LIBTORCH_VERSION}%2Bcpu.zip
sudo unzip /tmp/libtorch-cxx11-abi-shared-with-deps-${LIBTORCH_VERSION}+cpu.zip -d $GOTCH/libtch
2020-10-10 22:45:49 +01:00
# Update .bashrc
2020-10-11 01:27:28 +01:00
FILE="$HOME/.bashrc"
LN_LIBTORCH="export LIBTORCH=$GOPATH/pkg/mod/github.com/sugarme/gotch@$GOTCH_VERSION/libtch/libtorch"
LN_LIBRARY_PATH="export LIBRARY_PATH=$LIBTORCH/lib"
LN_CPATH="export CPATH=$LIBTORCH/lib:$LIBTORCH/include:$LIBTORCH/include/torch/csrc:$LIBTORCH/include/torch/csrc/api/include"
LN_LD_LIBRARY_PATH="export LD_LIBRARY_PATH=$LIBTORCH/lib:$LD_LIBRARY_PATH"
2020-10-11 13:14:21 +01:00
sudo grep -xqF -- "$LN_LIBTORCH" "$FILE" || sudo echo "$LN_LIBTORCH" >> "$FILE"
sudo grep -xqF -- "$LN_LIBRARY_PATH" "$FILE" || sudo echo "$LN_LIBRARY_PATH" >> "$FILE"
sudo grep -xqF -- "$LN_CPATH" "$FILE" || sudo echo "$LN_CPATH" >> "$FILE"
sudo grep -xqF -- "$LN_LD_LIBRARY_PATH" "$FILE" || sudo echo "$LN_LD_LIBRARY_PATH" >> "$FILE"
2020-10-10 22:45:49 +01:00
2020-10-11 01:27:28 +01:00
sudo rm $GOTCH/libtch/lib.go
sudo cp $GOTCH/libtch/lib.go.cpu $GOTCH/libtch/lib.go
sudo mv $GOTCH/libtch/dummy_cuda_dependency.cpp $GOTCH/libtch/dummy_cuda_dependency.cpp.gpu
sudo mv $GOTCH/libtch/fake_cuda_dependency.cpp.cpu $GOTCH/libtch/fake_cuda_dependency.cpp
source "$FILE"