Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running tutorials on MacOS results in error. #1424

Open
NiklasGustafsson opened this issue Dec 12, 2024 · 2 comments
Open

Running tutorials on MacOS results in error. #1424

NiklasGustafsson opened this issue Dec 12, 2024 · 2 comments
Assignees

Comments

@NiklasGustafsson
Copy link
Contributor

Trying to run tutorial1.ipynb on MacOS-Arm64

https://github.com/dotnet/TorchSharpExamples/blob/main/tutorials/CSharp/tutorial1.ipynb

results in an error on the first TorchSharp invocation. It's dynamically looking for the wrong libtorch version number, '2.5.1.0' instead of '2.5.1'

Installed Packages
libtorch-cpu-osx-arm64, 2.5.1
TorchSharp-cpu, 0.105.0

Error: System.TypeInitializationException: The type initializer for 'TorchSharp.torch' threw an exception.
---> System.NotSupportedException: The libtorch-cpu-osx-arm64 package version 2.5.1.0 is not restored on this system. If using F# Interactive or .NET Interactive you may need to add a reference to this package, e.g.
#r "nuget: libtorch-cpu-osx-arm64, 2.5.1.0". Trace from LoadNativeBackend:

TorchSharp: LoadNativeBackend: Initialising native backend, useCudaBackend = False

This only seems to happen on MacOS, running tutorials on Windows works fine.

@ozanMSFT
Copy link

ozanMSFT commented Dec 13, 2024

Hey @NiklasGustafsson , thanks for the report.

By meaning the first invocation, are you referring this code section in the tutorial1.ipynb?

using TorchSharp;

using static TorchSharp.torch.nn;
using static TorchSharp.torch.nn.functional;
using static TorchSharp.TensorExtensionMethods;

I'm trying to verify if issue is related to notebook or TorchSharp itself.

@NiklasGustafsson
Copy link
Contributor Author

NiklasGustafsson commented Dec 13, 2024

No, you have to go farther down the notebook, when it first creates a tensor. Before then, nothing is run.

I believe it has to do with .NET Interactive, and how TorchSharp loads the backend dynamically. For some reason, it's not affecting Windows (haven't tried tutorials on Linux).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants