dotnet / TorchSharp

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

Create combo packages #348

Open dsyme opened 3 years ago

dsyme commented 3 years ago

Part of the problem underlying stuff like #347 is the need for this "loading logic" in TorchSharp at all, it's a mess especially the cases for F# Interactive.

On talking it through with @gbaydin, one suggestion was that we should add "runtime ready" combo packages that combine TorchSharp with the appropriate runtime, and also have these ensure that on package restore the native binaries are put together in a place loadable by F# Interactive and .NET Interactive, without any hassle or initialization code.

These would be the three combo packages:

The above are in addition to the existing packages:

It's important to still have the plain "TorchSharp" package because this is what things like DiffSharp.Backend.Torch reference - it's the programming model with (most) of its implementation, but short of the selected libtorch native binaries.

dsyme commented 3 years ago

Note we use combo packages in DiffSharp to give a single package to reference - the above would also simplify DiffSharp and correctly put the sanity checking for an overall valid set of references in TorchSharp

gbaydin commented 3 years ago

Sounds great!

NiklasGustafsson commented 3 years ago

What about MacOS? No need for a combo?

gbaydin commented 3 years ago

I think libtorch-cpu covers all of linux, macos, windows and there is no libtorch-cuda because libtorch doesn't support cuda on macos. See below from https://pytorch.org/get-started/locally/

Screenshot_2021-09-21_18-30-08

dsyme commented 3 years ago

This is done, but we need to check pacakges are building in main and then republish

dsyme commented 3 years ago

Note that what's been done so far doesn't adjust the package restore behaviour, so we should leave this open and consider doing that separately

and also have these ensure that on package restore the native binaries are put together in a place loadable by F# Interactive and .NET Interactive, without any hassle or initialization code.