Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib 2, stdenv 3, addOpenGLRunpath 4, autoPatchelfHook 5, buildPythonPackage 6, cudaPackages 7, fetchurl 8, pythonAtLeast 9, pythonOlder 10, pillow 11, python 12, torch-bin 13}: 14 15let 16 pyVerNoDot = builtins.replaceStrings [ "." ] [ "" ] python.pythonVersion; 17 srcs = import ./binary-hashes.nix version; 18 unsupported = throw "Unsupported system"; 19 version = "0.15.2"; 20in buildPythonPackage { 21 inherit version; 22 23 pname = "torchvision"; 24 25 format = "wheel"; 26 27 src = fetchurl srcs."${stdenv.system}-${pyVerNoDot}" or unsupported; 28 29 disabled = (pythonOlder "3.8") || (pythonAtLeast "3.12"); 30 31 buildInputs = with cudaPackages; [ 32 # $out/${sitePackages}/torchvision/_C.so wants libcudart.so.11.0 but torchvision.libs only ships 33 # libcudart.$hash.so.11.0 34 cuda_cudart 35 ]; 36 37 nativeBuildInputs = [ 38 autoPatchelfHook 39 addOpenGLRunpath 40 ]; 41 42 propagatedBuildInputs = [ 43 pillow 44 torch-bin 45 ]; 46 47 # The wheel-binary is not stripped to avoid the error of `ImportError: libtorch_cuda_cpp.so: ELF load command address/offset not properly aligned.`. 48 dontStrip = true; 49 50 pythonImportsCheck = [ "torchvision" ]; 51 52 preInstall = '' 53 addAutoPatchelfSearchPath "${torch-bin}/${python.sitePackages}/torch" 54 ''; 55 56 meta = with lib; { 57 description = "PyTorch vision library"; 58 homepage = "https://pytorch.org/"; 59 changelog = "https://github.com/pytorch/vision/releases/tag/v${version}"; 60 # Includes CUDA and Intel MKL, but redistributions of the binary are not limited. 61 # https://docs.nvidia.com/cuda/eula/index.html 62 # https://www.intel.com/content/www/us/en/developer/articles/license/onemkl-license-faq.html 63 license = licenses.bsd3; 64 sourceProvenance = with sourceTypes; [ binaryNativeCode ]; 65 platforms = [ "x86_64-linux" ]; 66 maintainers = with maintainers; [ junjihashimoto ]; 67 }; 68}