TorchSharp icon indicating copy to clipboard operation
TorchSharp copied to clipboard

Create combo packages

Open dsyme opened this issue 4 years ago • 6 comments

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:

  • TorchSharp-cpu

    • references matching TorchSharp package
    • references matching libtorch-cpu package
    • on restore, ensures that native binaries are all available in one known directory
  • TorchSharp-cuda-11.1-linux-x64

    • references matching TorchSharp package
    • references matching matching libtorch-cuda-11.1-linux-x64 package
    • on restore, ensures that native binaries are all available in one known directory
  • TorchSharp-cuda-11.1-windows-x64

    • references matching TorchSharp package
    • references matching libtorch-cuda-11.1-windows package
    • on restore, ensures that native binaries are all available in one known directory

The above are in addition to the existing packages:

  • TorchSharp

    • contains managed component
    • contains one native component
  • libtorch-cpu

  • libtorch-cuda-11.1-linux-x64

    • plus various "fragment" packages for delivery
    • on restore, restitches fragments
  • libtorch-cuda-11.1-windows-x64

    • plus various "fragment" packages for delivery
    • on restore, restitches fragments

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 avatar Sep 13 '21 23:09 dsyme

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

dsyme avatar Sep 14 '21 00:09 dsyme

Sounds great!

gbaydin avatar Sep 14 '21 11:09 gbaydin

What about MacOS? No need for a combo?

NiklasGustafsson avatar Sep 21 '21 16:09 NiklasGustafsson

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

gbaydin avatar Sep 21 '21 16:09 gbaydin

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

dsyme avatar Oct 06 '21 18:10 dsyme

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.

dsyme avatar Oct 06 '21 18:10 dsyme