2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
buildPythonPackage,
|
|
|
|
fetchFromGitHub,
|
|
|
|
lib,
|
|
|
|
libjpeg_turbo,
|
|
|
|
libpng,
|
|
|
|
ninja,
|
|
|
|
numpy,
|
|
|
|
pillow,
|
|
|
|
pytest,
|
|
|
|
scipy,
|
|
|
|
torch,
|
|
|
|
which,
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2021-08-08 23:34:03 +00:00
|
|
|
let
|
2023-03-24 00:07:29 +00:00
|
|
|
inherit (torch) cudaCapabilities cudaPackages cudaSupport;
|
2024-01-02 11:29:13 +00:00
|
|
|
inherit (cudaPackages) backendStdenv;
|
2023-03-15 16:39:30 +00:00
|
|
|
|
2021-01-05 17:05:55 +00:00
|
|
|
pname = "torchvision";
|
2024-09-19 14:19:46 +00:00
|
|
|
version = "0.19.0";
|
2023-03-15 16:39:30 +00:00
|
|
|
in
|
|
|
|
buildPythonPackage {
|
|
|
|
inherit pname version;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-05 17:05:55 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "pytorch";
|
|
|
|
repo = "vision";
|
2022-08-12 12:06:08 +00:00
|
|
|
rev = "refs/tags/v${version}";
|
2024-09-19 14:19:46 +00:00
|
|
|
hash = "sha256-OVwdEqKEoZR1jtcg4ODyvIZvP9UQPodPv8qnTqbA/pc=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
libpng
|
|
|
|
ninja
|
|
|
|
which
|
2024-06-05 15:53:02 +00:00
|
|
|
] ++ lib.optionals cudaSupport [ cudaPackages.cuda_nvcc ];
|
2021-01-05 17:05:55 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
buildInputs = [
|
|
|
|
libjpeg_turbo
|
|
|
|
libpng
|
|
|
|
torch.cxxdev
|
|
|
|
];
|
2021-01-05 17:05:55 +00:00
|
|
|
|
2024-06-20 14:57:18 +00:00
|
|
|
dependencies = [
|
2024-06-05 15:53:02 +00:00
|
|
|
numpy
|
|
|
|
pillow
|
|
|
|
torch
|
|
|
|
scipy
|
|
|
|
];
|
2021-01-05 17:05:55 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
preConfigure =
|
|
|
|
''
|
|
|
|
export TORCHVISION_INCLUDE="${libjpeg_turbo.dev}/include/"
|
|
|
|
export TORCHVISION_LIBRARY="${libjpeg_turbo}/lib/"
|
|
|
|
''
|
|
|
|
# NOTE: We essentially override the compilers provided by stdenv because we don't have a hook
|
|
|
|
# for cudaPackages to swap in compilers supported by NVCC.
|
|
|
|
+ lib.optionalString cudaSupport ''
|
|
|
|
export CC=${backendStdenv.cc}/bin/cc
|
|
|
|
export CXX=${backendStdenv.cc}/bin/c++
|
|
|
|
export TORCH_CUDA_ARCH_LIST="${lib.concatStringsSep ";" cudaCapabilities}"
|
|
|
|
export FORCE_CUDA=1
|
|
|
|
'';
|
2021-08-08 23:34:03 +00:00
|
|
|
|
2021-01-05 17:05:55 +00:00
|
|
|
# tries to download many datasets for tests
|
|
|
|
doCheck = false;
|
|
|
|
|
2023-03-15 16:39:30 +00:00
|
|
|
pythonImportsCheck = [ "torchvision" ];
|
2021-01-05 17:05:55 +00:00
|
|
|
checkPhase = ''
|
|
|
|
HOME=$TMPDIR py.test test --ignore=test/test_datasets_download.py
|
|
|
|
'';
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [ pytest ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-06-20 14:57:18 +00:00
|
|
|
meta = {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "PyTorch vision library";
|
2021-01-05 17:05:55 +00:00
|
|
|
homepage = "https://pytorch.org/";
|
2024-09-19 14:19:46 +00:00
|
|
|
changelog = "https://github.com/pytorch/vision/releases/tag/v${version}";
|
2024-06-20 14:57:18 +00:00
|
|
|
license = lib.licenses.bsd3;
|
|
|
|
platforms = with lib.platforms; linux ++ lib.optionals (!cudaSupport) darwin;
|
|
|
|
maintainers = with lib.maintainers; [ ericsagnes ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|