dotnet / TorchSharp

A .NET library that provides access to the library that powers PyTorch.
MIT License
1.4k stars 182 forks source link

DLL load error #1222

Open rangerbottle opened 9 months ago

rangerbottle commented 9 months ago

I am trying to use latest TorchSharp in my C# project .

Running TorchSharp program as an standalone exe throws no errors and outputs just fine.

However, when referencing the dll with the exact same csproj and project setup returns the error.

The error message are: System.NotSupportedException: This application or script uses TorchSharp but doesn't contain a reference to libtorch-cpu-win-x64, Version=2.1.0.1

I have copied all the libtorch dlls from nuget folder to the same folder contains TorchSharp.dll and project dll and made sure to compile at x64, and still the reference isn’t being recognized.

I would like to ask your help for this issue. Thanks in advance

NiklasGustafsson commented 9 months ago

What TorchSharp packages are you using?

rangerbottle commented 9 months ago

TorchSharp Latest version: 0.101.5 libtorch-cpu-win-x64 Latest version: 2.1.0.1 Pytorch 2.1.0 Python 3.9 Visual Studio 2022

dustincoding commented 9 months ago

I solved a similar issue for myself (maybe not exactly the same). See if this helps: https://github.com/dotnet/TorchSharp/issues/1218

rangerbottle commented 9 months ago

I solved a similar issue for myself (maybe not exactly the same). See if this helps: #1218

Thanks a lot~I will try