updated README

This commit is contained in:
sugarme 2020-10-11 22:25:58 +11:00
parent f455029f08
commit 1ca5b38f13
3 changed files with 11 additions and 48 deletions

View File

@ -3,66 +3,29 @@
## Overview
- **GoTch** is a C++ Libtorch Go binding for developing and implementing deep
learning projects in Go.
- It is currently in heavy development mode and is considered **unstable** until
version v1.0.0 is marked. Hence, one can use it with own risk.
- This package is to create a thin wrapper of Libtorch to make use of
its tensor APIs and CUDA support while implementing as much
idiomatic Go as possible.
- **GoTch** is a C++ Libtorch Go binding for developing and implementing deep learning projects in Go.
- This package is to create a thin wrapper of Libtorch to make use of its tensor APIs and CUDA support while implementing as much idiomatic Go as possible.
## Dependencies
- **Libtorch** C++ v1.5.0 library of [Pytorch](https://pytorch.org/)
- Make sure that a libtorch version 1.5.0 (either CPU or CUDA support) is
installed in your system (at "/opt/libtorch" in Linux/Mac OS).
- Update `.bashrc` file to include `libtorch` in `LD_LIBRARY_PATH`
```bash
# .bashrc file
export LIBTORCH=/opt/libtorch
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/include:${LIBTORCH}:${LIBTORCH}/lib:${LIBTORCH}/include:${LIBTORCH}/include/torch/csrc/api/include
```
- Alternatively, just execute corresponding command to setup Libtorch C++
+ **CPU**
```bash
curl https://drive.google.com/file/d/1z7jwA2Zg4Qqw5BZS72V4k8vbPdxaQvqv/view?usp=sharing -sSf | bash
```
+ **GPU Cuda 10.1**
```bash
curl https://drive.google.com/file/d/1DQNF7kzhsj7T63WPyogOl0wc_gC1sf6x/view?usp=sharing -sSf | bash
```
## How to use
## Installation
- **CPU**
```bash
go get -u github.com/sugarme/gotch@cpu
go get -u github.com/sugarme/gotch@latest
bash ${GOPATH}/pkg/mod/github.com/sugarme/gotch@latest/setup-libtorch-cpu.sh
```
- **GPU**
```bash
go get -u github.com/sugarme/gotch
go get -u github.com/sugarme/gotch@latest
bash ${GOPATH}/pkg/mod/github.com/sugarme/gotch@latest/setup-libtorch-gpu-cu101.sh
```

4
setup-libtorch-cpu.sh Normal file → Executable file
View File

@ -1,7 +1,7 @@
#!/bin/bash
# Env
GOTCH_VERSION="v0.1.3"
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"
@ -12,7 +12,7 @@ LD_LIBRARY_PATH="$LIBTORCH/lib"
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 $LIBTORCH
sudo unzip /tmp/libtorch-cxx11-abi-shared-with-deps-1.5.1+cpu.zip -d $GOTCH/libtch
# Update .bashrc
FILE="$HOME/.bashrc"

4
setup-libtorch-gpu-cu101.sh Normal file → Executable file
View File

@ -1,6 +1,6 @@
#!/bin/bash
GOTCH_VERSION="v0.1.3"
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"
@ -11,7 +11,7 @@ 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 $LIBTORCH
sudo unzip /tmp/libtorch-cxx11-abi-shared-with-deps-1.5.1%2Bcu101.zip -d $GOTCH/libtch
# update .bashrc
FILE="$HOME/.bashrc"