updated scripts
This commit is contained in:
parent
1ca5b38f13
commit
a6830b3de5
|
@ -15,17 +15,21 @@
|
|||
|
||||
- **CPU**
|
||||
|
||||
Default values: `LIBTORCH_VER=1.5.1` and `GOTCH_VER=latest`
|
||||
|
||||
```bash
|
||||
go get -u github.com/sugarme/gotch@latest
|
||||
bash ${GOPATH}/pkg/mod/github.com/sugarme/gotch@latest/setup-libtorch-cpu.sh
|
||||
bash ${GOPATH}/pkg/mod/github.com/sugarme/gotch@latest/setup-cpu.sh
|
||||
|
||||
```
|
||||
|
||||
- **GPU**
|
||||
|
||||
Default values: `LIBTORCH_VER=1.5.1`, `CUDA_VER=10.1` and `GOTCH_VER=latest`
|
||||
|
||||
```bash
|
||||
go get -u github.com/sugarme/gotch@latest
|
||||
bash ${GOPATH}/pkg/mod/github.com/sugarme/gotch@latest/setup-libtorch-gpu-cu101.sh
|
||||
bash ${GOPATH}/pkg/mod/github.com/sugarme/gotch@latest/setup-gpu.sh
|
||||
|
||||
```
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Env
|
||||
GOTCH_VERSION="latest"
|
||||
GOTCH_VERSION="${GOTCH_VER:-latest}"
|
||||
LIBTORCH_VERSION="${LIBTORCH_VER:-1.5.1}"
|
||||
|
||||
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"
|
||||
|
@ -11,8 +13,8 @@ LD_LIBRARY_PATH="$LIBTORCH/lib"
|
|||
# Precompiled libtorch
|
||||
sudo rm -rf $LIBTORCH
|
||||
sudo mkdir -p $LIBTORCH
|
||||
wget -O /tmp/libtorch-cxx11-abi-shared-with-deps-1.5.1+cpu.zip https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-1.5.1%2Bcpu.zip
|
||||
sudo unzip /tmp/libtorch-cxx11-abi-shared-with-deps-1.5.1+cpu.zip -d $GOTCH/libtch
|
||||
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
|
||||
|
||||
# Update .bashrc
|
||||
FILE="$HOME/.bashrc"
|
||||
|
@ -20,10 +22,10 @@ LN_LIBTORCH="export LIBTORCH=$GOPATH/pkg/mod/github.com/sugarme/gotch@$GOTCH_VER
|
|||
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"
|
||||
sudo grep -qF -- "$LN_LIBTORCH" "$FILE" || sudo echo "$LN_LIBTORCH" >> "$FILE"
|
||||
sudo grep -qF -- "$LN_LIBRARY_PATH" "$FILE" || sudo echo "$LN_LIBRARY_PATH" >> "$FILE"
|
||||
sudo grep -qF -- "$LN_CPATH" "$FILE" || sudo echo "$LN_CPATH" >> "$FILE"
|
||||
sudo grep -qF -- "$LN_LD_LIBRARY_PATH" "$FILE" || sudo echo "$LN_LD_LIBRARY_PATH" >> "$FILE"
|
||||
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"
|
||||
|
||||
sudo rm $GOTCH/libtch/lib.go
|
||||
sudo cp $GOTCH/libtch/lib.go.cpu $GOTCH/libtch/lib.go
|
32
setup-gpu.sh
Executable file
32
setup-gpu.sh
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/bin/bash
|
||||
|
||||
GOTCH_VERSION="${GOTCH_VER:-latest}"
|
||||
LIBTORCH_VERSION="${LIBTORCH_VER:-1.5.1}"
|
||||
CUDA_VERSION="${CUDA_VER:-10.1}"
|
||||
CU_VERSION="${CUDA_VERSION//./}"
|
||||
|
||||
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="$CPATH:$LIBTORCH/lib:$LIBTORCH/include:$LIBTORCH/include/torch/csrc/api/include"
|
||||
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$LIBTORCH/lib:/usr/lib64-nvidia:/usr/local/cuda-${CUDA_VERSION}/lib64"
|
||||
|
||||
sudo rm -rf $LIBTORCH
|
||||
sudo mkdir -p $LIBTORCH
|
||||
|
||||
|
||||
wget -O /tmp/libtorch-cxx11-abi-shared-with-deps-${LIBTORCH_VERSION}%2B${CUDA_VERSION}.zip https://download.pytorch.org/libtorch/cu${CU_VERSION}/libtorch-cxx11-abi-shared-with-deps-${LIBTORCH_VERSION}%2Bcu${CU_VERSION}.zip
|
||||
sudo unzip /tmp/libtorch-cxx11-abi-shared-with-deps-${LIBTORCH_VERSION}%2Bcu${CU_VERSION}.zip -d $GOTCH/libtch
|
||||
|
||||
# update .bashrc
|
||||
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=$CPATH:$LIBTORCH/lib:$LIBTORCH/include:$LIBTORCH/include/torch/csrc/api/include"
|
||||
LN_LD_LIBRARY_PATH="export LD_LIBRARY_PATH=$LIBTORCH/lib:/usr/lib64-nvidia:/usr/local/cuda-${CUDA_VERSION}/lib64"
|
||||
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"
|
||||
|
||||
source "$FILE"
|
|
@ -1,27 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
GOTCH_VERSION="latest"
|
||||
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="$CPATH:$LIBTORCH/lib:$LIBTORCH/include:$LIBTORCH/include/torch/csrc/api/include"
|
||||
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$LIBTORCH/lib:/usr/lib64-nvidia:/usr/local/cuda-10.1/lib64"
|
||||
|
||||
sudo rm -rf $LIBTORCH
|
||||
sudo mkdir -p $LIBTORCH
|
||||
|
||||
wget -O /tmp/libtorch-cxx11-abi-shared-with-deps-1.5.1%2Bcu101.zip https://download.pytorch.org/libtorch/cu101/libtorch-cxx11-abi-shared-with-deps-1.5.1%2Bcu101.zip
|
||||
sudo unzip /tmp/libtorch-cxx11-abi-shared-with-deps-1.5.1%2Bcu101.zip -d $GOTCH/libtch
|
||||
|
||||
# update .bashrc
|
||||
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=$CPATH:$LIBTORCH/lib:$LIBTORCH/include:$LIBTORCH/include/torch/csrc/api/include"
|
||||
LN_LD_LIBRARY_PATH="export LD_LIBRARY_PATH=$LIBTORCH/lib:/usr/lib64-nvidia:/usr/local/cuda-10.1/lib64"
|
||||
sudo grep -qF -- "$LN_LIBTORCH" "$FILE" || sudo echo "$LN_LIBTORCH" >> "$FILE"
|
||||
sudo grep -qF -- "$LN_LIBRARY_PATH" "$FILE" || sudo echo "$LN_LIBRARY_PATH" >> "$FILE"
|
||||
sudo grep -qF -- "$LN_CPATH" "$FILE" || sudo echo "$LN_CPATH" >> "$FILE"
|
||||
sudo grep -qF -- "$LN_LD_LIBRARY_PATH" "$FILE" || sudo echo "$LN_LD_LIBRARY_PATH" >> "$FILE"
|
||||
|
||||
source "$FILE"
|
Loading…
Reference in New Issue
Block a user