Hello,
I’m trying to get hasktorch compiled in nix using haskell.nix. Currently I’m encountering an error during one of the sub libraries of hasktorch called libtorch-ffi
. I believe the error is caused by the inability (missing foreign-library support · Issue #465 · NixOS/cabal2nix · GitHub) for . This results in the following error during compilation:cabal2nix
to pickup the foreign libraries flags in libtorch-ffi
’s .cabal
file
[ 43 of 105] Compiling Torch.Internal.Managed.Native.Native9 ( src/Torch/Internal/Managed/Native/Native9.hs, dist/build/Torch/Internal/Managed/Native/Native9.p_o )
[ 44 of 105] Compiling Torch.Internal.Managed.Native ( src/Torch/Internal/Managed/Native.hs, dist/build/Torch/Internal/Managed/Native.p_o )
[ 45 of 105] Compiling Torch.Internal.Unmanaged.Optim ( src/Torch/Internal/Unmanaged/Optim.hs, dist/build/Torch/Internal/Unmanaged/Optim.p_o )
<command-line>: error: expected identifier before numeric constant
<command-line>: error: expected ‘}’ before numeric constant
In file included from /nix/store/75jl927al5mblqd0l42i0103955fswj4-python3.10-torch-2.0.0.0-dev/include/torch/csrc/jit/api/function_impl.h:5,
from /nix/store/75jl927al5mblqd0l42i0103955fswj4-python3.10-torch-2.0.0.0-dev/include/torch/csrc/jit/api/method.h:7,
from /nix/store/75jl927al5mblqd0l42i0103955fswj4-python3.10-torch-2.0.0.0-dev/include/torch/csrc/jit/api/object.h:6,
from /nix/store/75jl927al5mblqd0l42i0103955fswj4-python3.10-torch-2.0.0.0-dev/include/torch/csrc/jit/api/module.h:4,
from /nix/store/75jl927al5mblqd0l42i0103955fswj4-python3.10-torch-2.0.0.0-dev/include/torch/csrc/api/include/torch/serialize/input-archive.h:6,
from /nix/store/75jl927al5mblqd0l42i0103955fswj4-python3.10-torch-2.0.0.0-dev/include/torch/csrc/api/include/torch/serialize/archive.h:3,
from /nix/store/75jl927al5mblqd0l42i0103955fswj4-python3.10-torch-2.0.0.0-dev/include/torch/csrc/api/include/torch/nn/pimpl.h:5,
from /nix/store/75jl927al5mblqd0l42i0103955fswj4-python3.10-torch-2.0.0.0-dev/include/torch/csrc/api/include/torch/optim/adagrad.h:3,
from /nix/store/75jl927al5mblqd0l42i0103955fswj4-python3.10-torch-2.0.0.0-dev/include/torch/csrc/api/include/torch/optim.h:3,
from /build/ghc3054_0/ghc_275.cpp:8:0: error:
/nix/store/75jl927al5mblqd0l42i0103955fswj4-python3.10-torch-2.0.0.0-dev/include/torch/csrc/jit/runtime/graph_executor.h:19:28: error:
note: to match this ‘{’
19 | enum ExecutorExecutionMode {
| ^
|
19 | enum ExecutorExecutionMode {
| ^
<command-line>: error: expected unqualified-id before numeric constant
Here is the section in libtorch-ffi
’s cabal file.
cxx-sources: csrc/hasktorch_finializer.cpp
c-sources: csrc/hasktorch_dump.c
install-includes: csrc/hasktorch_finializer.h
,csrc/hasktorch_dump.h
include-dirs: csr
I’ve tried adding csrc
to libtorch-ffi’s project settings in cabalProject'
packages.libtorch-ffi = {
configureFlags = [
"--extra-include-dirs=${lib.getDev torch}/include/torch/csrc/api/include"
"--extra-include-dirs=${../libtorch-ffi/csrc}"
];
flags = {
cuda = cudaSupport;
rocm = false;
gcc = !cudaSupport && stdenv.hostPlatform.isDarwin;
};
};
But unfortunately the error remains. Any ideas on how I can fix this?