2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
stdenv,
|
|
|
|
addOpenGLRunpath,
|
|
|
|
autoPatchelfHook,
|
|
|
|
buildPythonPackage,
|
|
|
|
cudaPackages,
|
|
|
|
fetchurl,
|
|
|
|
pythonAtLeast,
|
|
|
|
pythonOlder,
|
|
|
|
pillow,
|
|
|
|
python,
|
|
|
|
torch-bin,
|
2021-05-20 23:08:51 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
pyVerNoDot = builtins.replaceStrings [ "." ] [ "" ] python.pythonVersion;
|
|
|
|
srcs = import ./binary-hashes.nix version;
|
|
|
|
unsupported = throw "Unsupported system";
|
2024-06-20 14:57:18 +00:00
|
|
|
version = "0.18.1";
|
2024-06-05 15:53:02 +00:00
|
|
|
in
|
|
|
|
buildPythonPackage {
|
2021-05-20 23:08:51 +00:00
|
|
|
inherit version;
|
|
|
|
|
|
|
|
pname = "torchvision";
|
|
|
|
|
|
|
|
format = "wheel";
|
|
|
|
|
|
|
|
src = fetchurl srcs."${stdenv.system}-${pyVerNoDot}" or unsupported;
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
disabled = (pythonOlder "3.8") || (pythonAtLeast "3.13");
|
2023-05-24 13:37:59 +00:00
|
|
|
|
2023-08-04 22:07:22 +00:00
|
|
|
# Note that we don't rely on config.cudaSupport here, because the Linux wheels all come built with CUDA support.
|
2024-06-05 15:53:02 +00:00
|
|
|
buildInputs =
|
|
|
|
with cudaPackages;
|
|
|
|
lib.optionals stdenv.isLinux [
|
|
|
|
# $out/${sitePackages}/torchvision/_C.so wants libcudart.so.11.0 but torchvision.libs only ships
|
|
|
|
# libcudart.$hash.so.11.0
|
|
|
|
cuda_cudart
|
|
|
|
];
|
2021-05-20 23:08:51 +00:00
|
|
|
|
2023-08-04 22:07:22 +00:00
|
|
|
nativeBuildInputs = lib.optionals stdenv.isLinux [
|
2023-05-24 13:37:59 +00:00
|
|
|
autoPatchelfHook
|
|
|
|
addOpenGLRunpath
|
2021-05-20 23:08:51 +00:00
|
|
|
];
|
|
|
|
|
2024-06-20 14:57:18 +00:00
|
|
|
dependencies = [
|
2021-05-20 23:08:51 +00:00
|
|
|
pillow
|
2022-09-09 14:08:57 +00:00
|
|
|
torch-bin
|
2021-05-20 23:08:51 +00:00
|
|
|
];
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
# The wheel-binary is not stripped to avoid the error of `ImportError: libtorch_cuda_cpp.so: ELF load command address/offset not properly aligned.`.
|
|
|
|
dontStrip = true;
|
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
pythonImportsCheck = [ "torchvision" ];
|
|
|
|
|
2023-08-04 22:07:22 +00:00
|
|
|
preInstall = lib.optionalString stdenv.isLinux ''
|
2023-05-24 13:37:59 +00:00
|
|
|
addAutoPatchelfSearchPath "${torch-bin}/${python.sitePackages}/torch"
|
2021-05-20 23:08:51 +00:00
|
|
|
'';
|
|
|
|
|
2024-06-20 14:57:18 +00:00
|
|
|
meta = {
|
2021-05-20 23:08:51 +00:00
|
|
|
description = "PyTorch vision library";
|
|
|
|
homepage = "https://pytorch.org/";
|
|
|
|
changelog = "https://github.com/pytorch/vision/releases/tag/v${version}";
|
2021-12-06 16:07:01 +00:00
|
|
|
# Includes CUDA and Intel MKL, but redistributions of the binary are not limited.
|
|
|
|
# https://docs.nvidia.com/cuda/eula/index.html
|
|
|
|
# https://www.intel.com/content/www/us/en/developer/articles/license/onemkl-license-faq.html
|
2024-06-20 14:57:18 +00:00
|
|
|
license = lib.licenses.bsd3;
|
|
|
|
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
|
2024-06-05 15:53:02 +00:00
|
|
|
platforms = [
|
|
|
|
"aarch64-darwin"
|
|
|
|
"x86_64-linux"
|
|
|
|
"aarch64-linux"
|
|
|
|
];
|
2024-06-20 14:57:18 +00:00
|
|
|
maintainers = with lib.maintainers; [ junjihashimoto ];
|
2021-05-20 23:08:51 +00:00
|
|
|
};
|
|
|
|
}
|