-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Description
I noticed that the only Tensorflow plugins provided for Unity ML Agents projects are for standalone/editor, iOS and Android. That said, I started exploring the possibility of producing a UWP build to support deployment to the Microsoft Store on Windows or Xbox One, and more specifically for Windows Mixed Reality projects (VR or HoloLens).
Looking at the TensorflowSharp package on Nuget, I see that versions 1.5 and 1.7 also include a .NET Standard 2.0 DLL, so I downloaded this package and imported it in my Unity ML Agent project as a WSA plugin only. Unless told otherwise, I am running under the assumption that the TF# 1.7 wrapper DLL can be used on top of TF 1.4 (which is what I am using).
I also copied the following files and configured them as WSA plugins since I assume that TF# also needs them as dependencies, just like the desktop/standalone plugin.
liblibtensorflow.so
libtensorflow.dll
libtensorflow.bundle
I switched my build target to UWP, and set the scripting backend to IL2CPP since that is the only backend that supports .NET Standard 2.0 API compatibility (to the best of my knowledge).
Since the current version of Newtonsoft JSON.NET packaged in Unity ML Agents is for .NET 4.6, I downloaded the Nuget package from https://www.nuget.org/packages/Newtonsoft.Json/11.0.2 and used the .NET Standard 2.0 DLL configured as a plugin in Unity for WSA. I changed the other DLL from all platforms to individually checking each platform except WSA.
I was able to produce a UWP build in Unity and successfully compile the UWP VC++ project in VS2017. The project runs but I get the following error at runtime:
DllNotFoundException: Unable to load DLL 'libtensorflow': the specified module could not be found.
(see attached screenshot)
This is where my limited knowledge of C++ and IL2CPP fails me (which is why I love using C# in Unity). The issue is probably tied to the libtensorflow.dll being a Win32 DLL and calling it from UWP isn't trivial. I'll start exploring there in the TF# source. If anyone has recommended options to fix this and produce a working UWP build, please let me know what I can try.