Skip to content

Latest commit

 

History

History
55 lines (33 loc) · 1.73 KB

README.md

File metadata and controls

55 lines (33 loc) · 1.73 KB

go-onnxruntime

Unofficial C binding for Onnxruntime in Golang. This is used to perform onnx model inference in Go.

Installation

Download and install go-onnxruntime :

go get -v github.com/ivansuteja96/go-onnxruntime

The binding requires Onnxruntime C++ and Go 1.14++.

Onnxruntime C++ Library

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 Environmental Variables

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).

How to Run

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

Examples of using the Go Onnxruntime binding to do model inference are under examples.

Credits

Some of the logic of conversion is referenced from https://github.com/c3sr/go-onnxruntime.