shaltielshmid / TorchSharp.PyBridge

A library enabling easy transfer and handling of PyTorch models between .NET and Python environments
MIT License
14 stars 3 forks source link

PyBridge 1.3.0 not loading on Apple Silicon #11

Closed NiklasGustafsson closed 6 months ago

NiklasGustafsson commented 6 months ago

I'm seeing this:

% dotnet run  
Loading Phi2 from huggingface model weight folder
Unhandled exception. System.BadImageFormatException: Could not load file or assembly 'TorchSharp.PyBridge, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null'. An attempt was made to load a program with an incorrect format.

File name: 'TorchSharp.PyBridge, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null'
   at PhiForCasualLM.FromPretrained(String modelFolder, String configName, String checkPointName, ScalarType defaultDType, String device)
   at Program.<Main>$(String[] args) in Torchsharp-phi/Program.cs:line 28
% 
shaltielshmid commented 6 months ago

Great catch! The package wasn't targeting the arm64 platform and therefore wasn't being recognized.

Should be fixed with https://github.com/shaltielshmid/TorchSharp.PyBridge/commit/00d739e374e257989bdfb6da0be43e5426c68a1e, uploaded to NuGet as version 1.3.1

NiklasGustafsson commented 6 months ago

Fix verified.