Unofficial C binding for Onnxruntime in Golang. This is used to perform onnx model inference in Go.
Download and install go-onnxruntime :
go get -v github.com/ivansuteja96/go-onnxruntime
The binding requires Onnxruntime C++ and Go 1.14++.
The C binding for Onnxruntime in Golang. This repository is built based on Onnxruntime v1.11.0.
To install Onnxruntime C++ on your system, you can go to onnxruntime and download the assets depends on your system (linux/mac).
The Onnxruntime C++ libraries are expected to be under /usr/local/lib
.
The Onnxruntime C++ header files are expected to be under /usrl/local/include
.
Configure the linker environmental variables since the Onnxruntime C++ library is under a non-system directory. Place the following in either your ~/.bashrc
or ~/.zshrc
file :
Linux (.bashrc) / macOS (.zshrc)
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
After that please run either source ~/.bashrc
(linux) or source ~/.zshrc
(macOS).
For the quick experience you can run go-onnxruntime using this command :
docker build --platform linux/arm64/v8 -f dockerfile/Dockerfile_ubuntu_arm64_example -t go-onnxruntime .
docker run --rm -it go-onnxruntime:latest
Note : Currently we only provide Dockerfile for ubuntu arm64 architecture.
Examples of using the Go Onnxruntime binding to do model inference are under examples.
Some of the logic of conversion is referenced from https://github.com/c3sr/go-onnxruntime.