1

I have successfully installed DiffSharp (along with TorchSharp, Libsharp etc.), using the following F# script:

#r "nuget: DiffSharp.Core"
#r "nuget: DiffSharp.Backends.Reference"
#r "nuget: DiffSharp.Data"
#r "nuget: DiffSharp.Backends.Torch"
#r "nuget: TorchSharp"
#r "nuget: LibTorchSharp"

open System
open DiffSharp
open DiffSharp.Data
open DiffSharp.Model
open DiffSharp.Compose
open DiffSharp.Util
open DiffSharp.Optim

The following functions however, are not available (which should be, according to the DiffSharp API reference):

dsharp.config(backend=Backend.Torch, device=Device.CPU)
dsharp.seed(1)
let x = dsharp.randn([1024; 5])

Any ideas why? Am I missing any library or open statement?

Loco Barocco
  • 121
  • 7

1 Answers1

1

I'm not sure why this is not working, but the DiffSharp installation isntructions recommend using the DiffSharp-cpu package (or one for cuda or lite version if you have LibTorch already) and that works fine for me:

#r "nuget: DiffSharp-cpu"

open DiffSharp

dsharp.config(backend=Backend.Torch, device=Device.CPU)
dsharp.seed(1)
let x = dsharp.randn([1024; 5])

Produces:

val x: Tensor =
  tensor([[-1.5256, -0.7502, -0.6540, -1.6095, -0.1002], ...])
Tomas Petricek
  • 240,744
  • 19
  • 378
  • 553
  • This actually did work, many thanks. Now, if I want to load the corresponding libraries (DLLs) directly from my HDD, any idea which ones to load (to speed things up)? Just loading DiffSharp-cpu.dll was not sufficient, and loading those I indicated earlier also causes the original problem again. – Loco Barocco Oct 28 '22 at 00:58