Download the libtorch dependency in ./libtorch
by downloading
an archive here e.g.
cpu-libtorch-cxx11-abi-shared-with-deps-latest.zip
$ curl -L https://github.com/hasktorch/libtorch-binary-for-ci/releases/download/1.8.0/cpu-libtorch-cxx11-abi-shared-with-deps-latest.zip >> libtorch.zip
$ unzip libtorch.zip
Reference hasktorch git commit in stack.yaml
extra-deps:
# ./stack.yaml
resolver: lts-17.4
packages:
- .
extra-deps:
- git: https://github.com/hasktorch/hasktorch.git
commit: 4e846fdcd89df5c7c6991cb9d6142007a6bb0a58
subdirs:
- hasktorch
- libtorch-ffi
- libtorch-ffi-helper
extra-include-dirs:
- libtorch/include/torch/csrc/api/include
- libtorch/include
extra-lib-dirs:
- ./libtorch/lib
Reference hasktorch in package.yaml
too:
# ./package.yaml
# ...
dependencies:
- base >= 4.7 && < 5
- hasktorch
You should then be able to load the library:
$ stack build
$ stack ghci
ghci> import Torch
ghci> :t asTensor [1, 2, 3]
Follow on to the tutorial here.