Change:
As per the title, the current CUDA and stdenv versions used to build are seemingly incompatible and can lead to build failures stating this (specifically - see below - but likely others as well). ~Likely introduced in ~ [of course it was the actual stdenv bump], but as it's a dynamic failure it's not a triviality to add an assert to to catch similar errors in future. with CUDA-enabled (e.g. in or override in ). Observe the build fails with the following output:
cc
This should be fixed when is merged.

Discussion:
<del> { lib , symlinkJoin , buildPythonPackage </del> <ins> { buildPythonPackage , cudaSupport ? torch.cudaSupport or false # by default uses the value from torch </ins> , fetchFromGitHub <del> , ninja , which </del> <ins> , lib </ins> , libjpeg_turbo , libpng <ins> , ninja </ins> , numpy <del> , scipy </del> , pillow <del> , torch </del> , pytest <del> , cudaSupport ? torch.cudaSupport or false # by default uses the value from torch </del> <ins> , scipy , symlinkJoin , torch , which </ins> }: let <del> inherit (torch) gpuTargetString; inherit (torch.cudaPackages) cudatoolkit cudnn; </del> <ins> inherit (torch) cudaPackages gpuTargetString; inherit (cudaPackages) cudatoolkit cudaFlags cudaVersion; # NOTE: torchvision doesn't use cudnn; torch does! #   For this reason it is not included. cuda-common-redist = with cudaPackages; [ cuda_cccl # <thrust/*> libcublas # cublas_v2.h libcusolver # cusolverDn.h libcusparse # cusparse.h ]; </ins> <del> cudatoolkit_joined = symlinkJoin { name = "${cudatoolkit.name}-unsplit"; paths = [ cudatoolkit.out cudatoolkit.lib ]; </del> <ins> cuda-native-redist = symlinkJoin { name = "cuda-native-redist-${cudaVersion}"; paths = with cudaPackages; [ cuda_cudart # cuda_runtime.h cuda_nvcc ] ++ cuda-common-redist; </ins> }; <del> in buildPythonPackage rec { </del> <ins> cuda-redist = symlinkJoin { name = "cuda-redist-${cudaVersion}"; paths = cuda-common-redist; }; </ins> pname = "torchvision"; version = "0.14.1"; <ins> in buildPythonPackage { inherit pname version; </ins> src = fetchFromGitHub { owner = "pytorch";

hash = "sha256-lKkEJolJQaLr1TVm44CizbJQedGa1wyy0cFWg2LTJN0="; }; <del> nativeBuildInputs = [ libpng ninja which ] ++ lib.optionals cudaSupport [ cudatoolkit_joined ]; TORCHVISION_INCLUDE = "${libjpeg_turbo.dev}/include/"; TORCHVISION_LIBRARY = "${libjpeg_turbo}/lib/"; </del> <ins> nativeBuildInputs = [ libpng ninja which ] ++ lib.optionals cudaSupport [ cuda-native-redist ]; </ins> <del> buildInputs = [ libjpeg_turbo libpng ] ++ lib.optionals cudaSupport [ cudnn ]; </del> <ins> buildInputs = [ libjpeg_turbo libpng ] ++ lib.optionals cudaSupport [ cuda-redist ]; </ins> propagatedBuildInputs = [ numpy pillow torch scipy ]; <del> preBuild = lib.optionalString cudaSupport '' </del> <ins> 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=${cudatoolkit.cc}/bin/cc export CXX=${cudatoolkit.cc}/bin/c++ export CUDAHOSTCXX=${cudatoolkit.cc}/bin/c++ </ins> export TORCH_CUDA_ARCH_LIST="${gpuTargetString}" export FORCE_CUDA=1 '';

# tries to download many datasets for tests doCheck = false; <ins> pythonImportsCheck = [ "torchvision" ]; </ins> checkPhase = '' HOME=$TMPDIR py.test test --ignore=test/test_datasets_download.py '';