2020-06-05 01:37:48 +01:00
|
|
|
# GoTch - Libtorch Go Binding
|
2020-06-05 01:36:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
## Overview
|
|
|
|
|
|
|
|
- **GoTch** is a C++ Libtorch Go binding for developing and implementing deep
|
|
|
|
learning projects in Go.
|
|
|
|
|
2020-06-05 01:53:07 +01:00
|
|
|
- It is currently in heavy development mode and is considered **unstable** until
|
2020-06-05 01:36:13 +01:00
|
|
|
version v1.0.0 is marked. Hence, one can use it with own risk.
|
|
|
|
|
|
|
|
- One goal of 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++ library of [Pytorch](https://pytorch.org/)
|
|
|
|
|
|
|
|
## How to use
|
|
|
|
|
|
|
|
### 1. Libtorch installation
|
|
|
|
|
|
|
|
- Make sure that a libtorch version 1.5.0 (either CPU or CUDA support) is
|
|
|
|
installed in your system (default at "/opt/libtorch" in Linux/Mac OS).
|
|
|
|
|
|
|
|
### 2. Import **GoTch** package
|
|
|
|
|
|
|
|
```go
|
|
|
|
package main
|
|
|
|
|
|
|
|
import(
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/sugarme/gotch"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main(){
|
|
|
|
|
|
|
|
var d gotch.Cuda
|
|
|
|
fmt.Printf("Cuda device count: %v\n", d.DeviceCount())
|
|
|
|
fmt.Printf("Cuda is available: %v\n", d.IsAvailable())
|
|
|
|
fmt.Printf("Cudnn is available: %v\n", d.CudnnIsAvailable())
|
|
|
|
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
- Other examples can be found at `example` folder
|
|
|
|
|
|
|
|
|
|
|
|
## Acknowledgement
|
|
|
|
|
|
|
|
- This projects has been inspired and used many concepts from [tch-rs](https://github.com/LaurentMazare/tch-rs)
|
|
|
|
Libtorch Rust binding.
|
|
|
|
|