Martin Weinelt 2022-08-30 20:42:49 +02:00
parent ac45560964
commit 9b183572a7
No known key found for this signature in database
GPG key ID: 87C1E9888F856759
3 changed files with 24 additions and 38 deletions

View file

@ -1,13 +0,0 @@
diff --git a/third_party/breakpad/src/client/linux/handler/exception_handler.cc b/third_party/breakpad/src/client/linux/handler/exception_handler.cc
index ca353c4099..499be0a986 100644
--- a/third_party/breakpad/src/client/linux/handler/exception_handler.cc
+++ b/third_party/breakpad/src/client/linux/handler/exception_handler.cc
@@ -138,7 +138,7 @@ void InstallAlternateStackLocked() {
// SIGSTKSZ may be too small to prevent the signal handlers from overrunning
// the alternative stack. Ensure that the size of the alternative stack is
// large enough.
- static const unsigned kSigStackSize = std::max(16384, SIGSTKSZ);
+ const unsigned kSigStackSize = std::max<unsigned>(16384, SIGSTKSZ);
// Only set an alternative stack if there isn't already one, or if the current
// one is too small.

View file

@ -122,31 +122,26 @@ let
in buildPythonPackage rec { in buildPythonPackage rec {
pname = "torch"; pname = "torch";
# Don't forget to update torch-bin to the same version. # Don't forget to update torch-bin to the same version.
version = "1.11.0"; version = "1.12.1";
format = "setuptools"; format = "setuptools";
disabled = pythonOlder "3.7.0"; disabled = pythonOlder "3.7.0";
outputs = [ outputs = [
"out" # output standard python package "out" # output standard python package
"dev" # output libtorch headers "dev" # output libtorch headers
"lib" # output libtorch libraries "lib" # output libtorch libraries
]; ];
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "pytorch"; owner = "pytorch";
repo = "pytorch"; repo = "pytorch";
rev = "v${version}"; rev = "refs/tags/v${version}";
fetchSubmodules = true; fetchSubmodules = true;
sha256 = "sha256-CEu63tdRBAF8CTchO3Qu8gUNObQylX6U08yDTI4/c/0="; hash = "sha256-8378BVOBFCRYRG1+yIYFSPKmb1rFOLgR+8pNZKt9NfI=";
}; };
patches = [ patches = lib.optionals (stdenv.isDarwin && stdenv.isx86_64) [
# Fix for a breakpad incompatibility with glibc>2.33
# https://github.com/pytorch/pytorch/issues/70297
# https://github.com/google/breakpad/commit/605c51ed96ad44b34c457bbca320e74e194c317e
./breakpad-sigstksz.patch
] ++ lib.optionals (stdenv.isDarwin && stdenv.isx86_64) [
# pthreadpool added support for Grand Central Dispatch in April # pthreadpool added support for Grand Central Dispatch in April
# 2020. However, this relies on functionality (DISPATCH_APPLY_AUTO) # 2020. However, this relies on functionality (DISPATCH_APPLY_AUTO)
# that is available starting with macOS 10.13. However, our current # that is available starting with macOS 10.13. However, our current
@ -208,7 +203,7 @@ in buildPythonPackage rec {
PYTORCH_BUILD_VERSION = version; PYTORCH_BUILD_VERSION = version;
PYTORCH_BUILD_NUMBER = 0; PYTORCH_BUILD_NUMBER = 0;
USE_SYSTEM_NCCL=setBool 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 # Suppress a weird warning in mkl-dnn, part of ideep in pytorch
# (upstream seems to have fixed this in the wrong place?) # (upstream seems to have fixed this in the wrong place?)
@ -243,15 +238,17 @@ in buildPythonPackage rec {
pillow six future tensorboard protobuf pillow six future tensorboard protobuf
] ++ lib.optionals MPISupport [ mpi ]; ] ++ lib.optionals MPISupport [ mpi ];
checkInputs = [ hypothesis ninja psutil ];
# Tests take a long time and may be flaky, so just sanity-check imports # Tests take a long time and may be flaky, so just sanity-check imports
doCheck = false; doCheck = false;
pythonImportsCheck = [ pythonImportsCheck = [
"torch" "torch"
]; ];
checkInputs = [ hypothesis ninja psutil ];
checkPhase = with lib.versions; with lib.strings; concatStringsSep " " [ checkPhase = with lib.versions; with lib.strings; concatStringsSep " " [
"runHook preCheck"
cudaStubEnv cudaStubEnv
"${python.interpreter} test/run_test.py" "${python.interpreter} test/run_test.py"
"--exclude" "--exclude"
@ -264,13 +261,15 @@ in buildPythonPackage rec {
# tensorboard has acceptable failures for pytorch 1.3.x due to dependencies on tensorboard-plugins # tensorboard has acceptable failures for pytorch 1.3.x due to dependencies on tensorboard-plugins
(optionalString (majorMinor version == "1.3" ) "tensorboard") (optionalString (majorMinor version == "1.3" ) "tensorboard")
]) ])
"runHook postCheck"
]; ];
postInstall = '' postInstall = ''
find "$out/${python.sitePackages}/torch/include" "$out/${python.sitePackages}/torch/lib" -type f -exec remove-references-to -t ${stdenv.cc} '{}' + find "$out/${python.sitePackages}/torch/include" "$out/${python.sitePackages}/torch/lib" -type f -exec remove-references-to -t ${stdenv.cc} '{}' +
mkdir $dev mkdir $dev
cp -r $out/${python.sitePackages}/torch/include $dev/include cp -r $out/${python.sitePackages}/torch/include $dev/include
cp -r $out/${python.sitePackages}/torch/share $dev/share cp -r $out/${python.sitePackages}/torch/share $dev/share
# Fix up library paths for split outputs # Fix up library paths for split outputs
substituteInPlace \ substituteInPlace \
@ -282,7 +281,7 @@ in buildPythonPackage rec {
--replace \''${_IMPORT_PREFIX}/lib "$lib/lib" --replace \''${_IMPORT_PREFIX}/lib "$lib/lib"
mkdir $lib mkdir $lib
mv $out/${python.sitePackages}/torch/lib $lib/lib mv $out/${python.sitePackages}/torch/lib $lib/lib
ln -s $lib/lib $out/${python.sitePackages}/torch/lib ln -s $lib/lib $out/${python.sitePackages}/torch/lib
''; '';
@ -312,11 +311,12 @@ in buildPythonPackage rec {
}; };
meta = with lib; { meta = with lib; {
description = "Open source, prototype-to-production deep learning platform"; changelog = "https://github.com/pytorch/pytorch/releases/tag/v${version}";
homepage = "https://pytorch.org/"; # keep PyTorch in the description so the package can be found under that name on search.nixos.org
license = licenses.bsd3; description = "PyTorch: Tensors and Dynamic neural networks in Python with strong GPU acceleration";
homepage = "https://pytorch.org/";
license = licenses.bsd3;
maintainers = with maintainers; [ teh thoughtpolice tscholak ]; # tscholak esp. for darwin-related builds maintainers = with maintainers; [ teh thoughtpolice tscholak ]; # tscholak esp. for darwin-related builds
platforms = with platforms; linux ++ lib.optionals (!cudaSupport) darwin; platforms = with platforms; linux ++ lib.optionals (!cudaSupport) darwin;
broken = stdenv.isLinux && stdenv.isAarch64;
}; };
} }

View file

@ -10929,7 +10929,6 @@ in {
torch-bin = callPackage ../development/python-modules/torch/bin.nix { }; torch-bin = callPackage ../development/python-modules/torch/bin.nix { };
torchWithCuda = self.torch.override { torchWithCuda = self.torch.override {
cudaSupport = true; cudaSupport = true;
}; };