losttech / Gradient

This repository serves as a public issue tracker and documentation host for Gradient, full TensorFlow binding for .NET
Other
86 stars 4 forks source link

Unity package #29

Open lostmsu opened 4 years ago

lostmsu commented 4 years ago

Ship a package for Unity

lostmsu commented 4 years ago

Moving this to 2.x for now. Current runtime is unable to survive reload of its assemblies.

Unofficially, you should be able to use TensorFlow in Unity by adding the following .NET Standard 2.0 assemblies from their respective NuGet packages:

Gradient.dll // will be renamed LostTech.TensorFlow.dll by RC0
IndexRange.dll
LostTech.Gradient.dll
LostTech.NumPy.dll
LostTech.WhichPython.dll
Python.Runtime.dll
SharPy.Runtime.dll
System.Buffers.dll
System.Memory.dll
System.Runtime.CompilerServices.Unsafe.dll
System.Security.Permissions.dll

And disabling Domain Reload.

Unfortunately Unity Editor will reload the domain regardless whenever the project is recompiled, after which an attempt to initialize Gradient again will crash the editor with Access Violation/segfault.

Extra hint: using GPU acceleration for TensorFlow requires CUDA and cudnn to be distributed (so an NVidia GPU). Calling tf.test.is_gpu_available() will tell if all components work as expected.