Hi all, I'm wanting to experiment with some machine learning in Unity and whilst ML-Agents seems very capable I would also like a solution that is .NET only. There is a wrapper for libtorch to provide the fundamentals and I'm trying to get that integrated into Unity. There seem to be a number of successful attempts at doing this and it should be a good learning exercise for me to understand the guts of C# a little (assemblies etc.). I have got the required packages installed in my Visual Studio solution via Nuget, which seem to be loaded ok, but I'm struggling getting Unity to load all the libraries. By copying the generic libraries into 'Assets/Plugins' Unity picks them up and tries to load it, but I don't know how to get the native runtime binaries to be referenced. Entering Play in Unity I get:
"NotSupportedException: This application or script uses TorchSharp but doesn't contain a reference to libtorch-cpu-win-x64, Version=2.5.1.0.
Consider referencing one of the combination packages TorchSharp-cpu, TorchSharp-cuda-linux, TorchSharp-cuda-windows or call System.Runtime.InteropServices.NativeLibrary.Load(path-to-LibTorchSharp.dll) explicitly for a Python install of pytorch. See https://github.com/dotnet/TorchSharp/issues/169.".
There is additional trace info just logging what and where it is trying to load, but is unable to find the libraries.
I have tried to create a response file, but get an error about missing metadata and won't compile any more:
'Assets\Plugins\TorchSharp\Windows\x86_64\LibTorchSharp.dll' could not be opened -- PE image doesn't contain managed metadata.
Unity knows it is native though, not managed. I also don't seem to be able to load it through script using the System... call above as NativeLibrary does not exist in .NET framework, only .NET core.
I am fully aware it is a lack of knowledge on my part, but I just can't seem to find the right resources/direction to learn from (likely missing something simple)!
Thanks, Daf!