Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: shell.nix that provides all the dependencies #162

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions libtorch-ffi/libtorch-ffi.cabal
Expand Up @@ -65,17 +65,17 @@ library
, async
extra-libraries: stdc++
, c10
, iomp5
, mklml
-- , iomp5 -- for now
-- , mklml
, torch
extra-ghci-libraries: stdc++
if os(darwin)
ld-options: -Wl,-keep_dwarf_unwind
ghc-options: -optc-D_GLIBCXX_USE_CXX11_ABI=0 -optc-std=c++11 -optc-xc++
ghc-options: -optc-D_GLIBCXX_USE_CXX11_ABI=1 -optc-std=c++11 -optc-xc++
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-optc-D_GLIBCXX_USE_CXX11_ABI=1 is a default option of gcc.
So we can just remove it to use CXX11_ABI.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Official page of pytorch provides libtorch of CXX11ABI.
So It ’s a good time to change.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! now I removed them.

else
ghc-options: -optc-D_GLIBCXX_USE_CXX11_ABI=0 -optc-std=c++11
cc-options: -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11
cxx-options: -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11
ghc-options: -optc-D_GLIBCXX_USE_CXX11_ABI=1 -optc-std=c++11
cc-options: -D_GLIBCXX_USE_CXX11_ABI=1 -std=c++11
cxx-options: -D_GLIBCXX_USE_CXX11_ABI=1 -std=c++11
default-extensions: Strict
, StrictData

Expand Down
58 changes: 58 additions & 0 deletions shell.nix
@@ -0,0 +1,58 @@
{ pkgs ?
let
# revision: https://github.com/NixOS/nixpkgs/pull/65041
rev = "9420c33455c5b3e0876813bdd739bc75b3ccbd8a";
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
# nix-prefetch-url --unpack ${url}
sha256 = "0l82qfcmip0mfijcxssaliyxayfh0c11bk66yhwna1ixc0s0jjd2";
nixpkgs = builtins.fetchTarball { inherit url sha256; };
in
import nixpkgs { config.allowUnfree = true; config.allowUnsupportedSystem = true; }
}:

with pkgs;

let

hsenv = haskellPackages.ghcWithPackages (p: with p; [
cabal-install
ansi-wl-pprint
async
bytestring
containers
exceptions
finite-typelits
ghc-typelits-knownnat
hashable
hspec
hspec-discover
mtl
optparse-applicative
parsec
parsers
QuickCheck
reflection
safe-exceptions
sysinfo
template-haskell
transformers
transformers-compat
unordered-containers
vector
]);

in

stdenv.mkDerivation {
name = "hasktorch-dev";
buildInputs = [ hsenv mkl python3Packages.pytorchWithoutCuda ];
shellHook =
let
libtorch_path = "${python3Packages.pytorchWithoutCuda}/lib/${python3Packages.python.libPrefix}/site-packages/torch";
in
''
export CPATH=${libtorch_path}/include/torch/csrc/api/include
export LD_LIBRARY_PATH=${libtorch_path}/lib
'';

}