From 4f876309fee0eabe5d48d2dc4e577266c61fe9f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20de=20Kok?= Date: Sat, 10 Apr 2021 08:08:08 +0200 Subject: [PATCH 1/3] python3Packages.pytorch: convert boolean environment variables We relied on the stdenv serialization for booleans. However, the PyTorch configure script expects 0/1. So convert the options to 0/1 values. --- pkgs/development/python-modules/pytorch/default.nix | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pkgs/development/python-modules/pytorch/default.nix b/pkgs/development/python-modules/pytorch/default.nix index 22a87b386e1..225bba02c61 100644 --- a/pkgs/development/python-modules/pytorch/default.nix +++ b/pkgs/development/python-modules/pytorch/default.nix @@ -38,6 +38,7 @@ assert !(MPISupport && cudaSupport) || mpi.cudatoolkit == cudatoolkit; assert !cudaSupport || magma.cudatoolkit == cudatoolkit; let + setBool = v: if v then "1" else "0"; cudatoolkit_joined = symlinkJoin { name = "${cudatoolkit.name}-unsplit"; # nccl is here purely for semantic grouping it could be moved to nativeBuildInputs @@ -160,16 +161,16 @@ in buildPythonPackage rec { # Use pytorch's custom configurations dontUseCmakeConfigure = true; - BUILD_NAMEDTENSOR = true; - BUILD_DOCS = buildDocs; + BUILD_NAMEDTENSOR = setBool true; + BUILD_DOCS = setBool buildDocs; - USE_MKL = blas.implementation == "mkl"; + USE_MKL = setBool (blas.implementation == "mkl"); # Unlike MKL, oneDNN (née MKLDNN) is FOSS, so we enable support for # it by default. PyTorch currently uses its own vendored version # of oneDNN through Intel iDeep. - USE_MKLDNN = mklDnnSupport; - USE_MKLDNN_CBLAS = mklDnnSupport; + USE_MKLDNN = setBool mklDnnSupport; + USE_MKLDNN_CBLAS = setBool mklDnnSupport; preBuild = '' export MAX_JOBS=$NIX_BUILD_CORES @@ -198,7 +199,7 @@ in buildPythonPackage rec { PYTORCH_BUILD_VERSION = version; PYTORCH_BUILD_NUMBER = 0; - USE_SYSTEM_NCCL=useSystemNccl; # don't build pytorch's third_party NCCL + USE_SYSTEM_NCCL=setBool useSystemNccl; # don't build pytorch's third_party NCCL # Suppress a weird warning in mkl-dnn, part of ideep in pytorch # (upstream seems to have fixed this in the wrong place?) From 209f4678f2639ead6b93a3a61687ab2b8166f1ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20de=20Kok?= Date: Sat, 10 Apr 2021 08:09:38 +0200 Subject: [PATCH 2/3] python3Packages.pytorch: disable building of tests - We do not run them. - The test binaries are installed into site-packages by default. --- pkgs/development/python-modules/pytorch/default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/development/python-modules/pytorch/default.nix b/pkgs/development/python-modules/pytorch/default.nix index 225bba02c61..1c0cc1b24f3 100644 --- a/pkgs/development/python-modules/pytorch/default.nix +++ b/pkgs/development/python-modules/pytorch/default.nix @@ -164,6 +164,9 @@ in buildPythonPackage rec { BUILD_NAMEDTENSOR = setBool true; BUILD_DOCS = setBool buildDocs; + # We only do an imports check, so do not build tests either. + BUILD_TEST = setBool false; + USE_MKL = setBool (blas.implementation == "mkl"); # Unlike MKL, oneDNN (née MKLDNN) is FOSS, so we enable support for From 0603c25738ab744f1ff61392bcea46055fb3b1b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20de=20Kok?= Date: Sat, 10 Apr 2021 08:10:28 +0200 Subject: [PATCH 3/3] python3Packages.pytorch: remove unused USE_MKL variable PyTorch will always try to find MKL, USE_MKL does not do anything anymore. So, we have to rely on MKL not being in the build environment. --- pkgs/development/python-modules/pytorch/default.nix | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkgs/development/python-modules/pytorch/default.nix b/pkgs/development/python-modules/pytorch/default.nix index 1c0cc1b24f3..22b8757cec8 100644 --- a/pkgs/development/python-modules/pytorch/default.nix +++ b/pkgs/development/python-modules/pytorch/default.nix @@ -167,8 +167,6 @@ in buildPythonPackage rec { # We only do an imports check, so do not build tests either. BUILD_TEST = setBool false; - USE_MKL = setBool (blas.implementation == "mkl"); - # Unlike MKL, oneDNN (née MKLDNN) is FOSS, so we enable support for # it by default. PyTorch currently uses its own vendored version # of oneDNN through Intel iDeep.