Skip to content

Commit

Permalink
python3Packages.torch: 1.11.0 -> 1.12.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mweinelt committed Aug 31, 2022
1 parent ac45560 commit 9b18357
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 38 deletions.
13 changes: 0 additions & 13 deletions pkgs/development/python-modules/torch/breakpad-sigstksz.patch

This file was deleted.

48 changes: 24 additions & 24 deletions pkgs/development/python-modules/torch/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -122,31 +122,26 @@ let
in buildPythonPackage rec {
pname = "torch";
# Don't forget to update torch-bin to the same version.
version = "1.11.0";
version = "1.12.1";
format = "setuptools";

disabled = pythonOlder "3.7.0";

outputs = [
"out" # output standard python package
"dev" # output libtorch headers
"lib" # output libtorch libraries
"out" # output standard python package
"dev" # output libtorch headers
"lib" # output libtorch libraries
];

src = fetchFromGitHub {
owner = "pytorch";
repo = "pytorch";
rev = "v${version}";
owner = "pytorch";
repo = "pytorch";
rev = "refs/tags/v${version}";
fetchSubmodules = true;
sha256 = "sha256-CEu63tdRBAF8CTchO3Qu8gUNObQylX6U08yDTI4/c/0=";
hash = "sha256-8378BVOBFCRYRG1+yIYFSPKmb1rFOLgR+8pNZKt9NfI=";
};

patches = [
# 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) [
patches = lib.optionals (stdenv.isDarwin && stdenv.isx86_64) [
# pthreadpool added support for Grand Central Dispatch in April
# 2020. However, this relies on functionality (DISPATCH_APPLY_AUTO)
# that is available starting with macOS 10.13. However, our current
Expand Down Expand Up @@ -208,7 +203,7 @@ in buildPythonPackage rec {
PYTORCH_BUILD_VERSION = version;
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
# (upstream seems to have fixed this in the wrong place?)
Expand Down Expand Up @@ -243,15 +238,17 @@ in buildPythonPackage rec {
pillow six future tensorboard protobuf
] ++ lib.optionals MPISupport [ mpi ];

checkInputs = [ hypothesis ninja psutil ];

# Tests take a long time and may be flaky, so just sanity-check imports
doCheck = false;

pythonImportsCheck = [
"torch"
];

checkInputs = [ hypothesis ninja psutil ];

checkPhase = with lib.versions; with lib.strings; concatStringsSep " " [
"runHook preCheck"
cudaStubEnv
"${python.interpreter} test/run_test.py"
"--exclude"
Expand All @@ -264,13 +261,15 @@ in buildPythonPackage rec {
# tensorboard has acceptable failures for pytorch 1.3.x due to dependencies on tensorboard-plugins
(optionalString (majorMinor version == "1.3" ) "tensorboard")
])
"runHook postCheck"
];

postInstall = ''
find "$out/${python.sitePackages}/torch/include" "$out/${python.sitePackages}/torch/lib" -type f -exec remove-references-to -t ${stdenv.cc} '{}' +
mkdir $dev
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
substituteInPlace \
Expand All @@ -282,7 +281,7 @@ in buildPythonPackage rec {
--replace \''${_IMPORT_PREFIX}/lib "$lib/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
'';

Expand Down Expand Up @@ -312,11 +311,12 @@ in buildPythonPackage rec {
};

meta = with lib; {
description = "Open source, prototype-to-production deep learning platform";
homepage = "https://pytorch.org/";
license = licenses.bsd3;
changelog = "https://github.com/pytorch/pytorch/releases/tag/v${version}";
# keep PyTorch in the description so the package can be found under that name on search.nixos.org
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
platforms = with platforms; linux ++ lib.optionals (!cudaSupport) darwin;
broken = stdenv.isLinux && stdenv.isAarch64;
platforms = with platforms; linux ++ lib.optionals (!cudaSupport) darwin;
};
}
1 change: 0 additions & 1 deletion pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10929,7 +10929,6 @@ in {

torch-bin = callPackage ../development/python-modules/torch/bin.nix { };


torchWithCuda = self.torch.override {
cudaSupport = true;
};
Expand Down

0 comments on commit 9b18357

Please sign in to comment.