python3Packages.torchvision-bin: init at 0.9.1

This derivation can be used in conjunction with pytorch-bin to avoid
the long build time of PyTorch/TorchVision CUDA builds.
This commit is contained in:
Daniël de Kok 2021-05-14 18:22:27 +02:00 committed by Jonathan Ringer
parent 2b467919c1
commit abd6f00001
3 changed files with 83 additions and 0 deletions

View file

@ -0,0 +1,59 @@
{ lib
, stdenv
, buildPythonPackage
, fetchurl
, isPy37
, isPy38
, isPy39
, patchelf
, pillow
, python
, pytorch-bin
}:
let
pyVerNoDot = builtins.replaceStrings [ "." ] [ "" ] python.pythonVersion;
srcs = import ./binary-hashes.nix version;
unsupported = throw "Unsupported system";
version = "0.9.1";
in buildPythonPackage {
inherit version;
pname = "torchvision";
format = "wheel";
src = fetchurl srcs."${stdenv.system}-${pyVerNoDot}" or unsupported;
disabled = !(isPy37 || isPy38 || isPy39);
nativeBuildInputs = [
patchelf
];
propagatedBuildInputs = [
pillow
pytorch-bin
];
pythonImportsCheck = [ "torchvision" ];
postFixup = let
rpath = lib.makeLibraryPath [ stdenv.cc.cc.lib ];
in ''
# Note: after patchelf'ing, libcudart can still not be found. However, this should
# not be an issue, because PyTorch is loaded before torchvision and brings
# in the necessary symbols.
patchelf --set-rpath "${rpath}:${pytorch-bin}/${python.sitePackages}/torch/lib:" \
"$out/${python.sitePackages}/torchvision/_C.so"
'';
meta = with lib; {
description = "PyTorch vision library";
homepage = "https://pytorch.org/";
changelog = "https://github.com/pytorch/vision/releases/tag/v${version}";
license = licenses.bsd3;
platforms = platforms.linux;
maintainers = with maintainers; [ danieldk ];
};
}

View file

@ -0,0 +1,22 @@
# Warning: use the same CUDA version as pytorch-bin.
#
# Precompiled wheels can be found at:
# https://download.pytorch.org/whl/torch_stable.html
version: {
x86_64-linux-37 = {
name = "torchvision-${version}-cp37-cp37m-linux_x86_64.whl";
url = "https://download.pytorch.org/whl/cu111/torchvision-${version}%2Bcu111-cp37-cp37m-linux_x86_64.whl";
hash = "sha256-7EMVB8KZg2I3P4RqnIVk/7OOAPA1OWOipns58cSCUrw=";
};
x86_64-linux-38 = {
name = "torchvision-${version}-cp38-cp38-linux_x86_64.whl";
url = "https://download.pytorch.org/whl/cu111/torchvision-${version}%2Bcu111-cp38-cp38-linux_x86_64.whl";
hash = "sha256-VjsCBW9Lusr4aDQLqaFh5dpV/5ZJ5PDs7nY4CbCHDTA=";
};
x86_64-linux-39 = {
name = "torchvision-${version}-cp39-cp39-linux_x86_64.whl";
url = "https://download.pytorch.org/whl/cu111/torchvision-${version}%2Bcu111-cp39-cp39-linux_x86_64.whl";
hash = "sha256-pzR7TBE+WcAmozskoeOVBuMkGJf9tvsaXsUkTcu86N8=";
};
}

View file

@ -8225,6 +8225,8 @@ in {
torchvision = callPackage ../development/python-modules/torchvision { };
torchvision-bin = callPackage ../development/python-modules/torchvision/bin.nix { };
tornado = callPackage ../development/python-modules/tornado { };
# Used by circus and grab-site, 2020-08-29