Unverified Commit 30ef5066 authored by Yt's avatar Yt Committed by GitHub
Browse files

python3Packages.paddlepaddle: fix evaluation error when selecting unsupported...

python3Packages.paddlepaddle: fix evaluation error when selecting unsupported cuda version (#478681)
parents 5980debf 5a9f5ec0
Loading
Loading
Loading
Loading
+16 −12
Original line number Diff line number Diff line
@@ -34,21 +34,25 @@ let
  version = sources.version;
  format = "wheel";
  pyShortVersion = "cp${builtins.replaceStrings [ "." ] [ "" ] python.pythonVersion}";
  hash =
    if cudaSupport then
      sources."${stdenv.hostPlatform.system}"."gpu"."cu${
        lib.replaceStrings [ "." ] [ "" ] cudaPackages.cudatoolkit.version
      }"."${pyShortVersion}"
    else
      sources."${stdenv.hostPlatform.system}"."cpu"."${pyShortVersion}"
        or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
  platform = sources."${stdenv.hostPlatform.system}".platform;
  cudaVersion = "cu${lib.replaceStrings [ "." ] [ "" ] cudaPackages.cudatoolkit.version}";

  throwSystem = throw "Unsupported system: ${stdenv.hostPlatform.system}";
  systemSources = sources."${stdenv.hostPlatform.system}" or throwSystem;

  supportedCudaVersions = lib.concatStringsSep ", " (builtins.attrNames systemSources.gpu);
  throwCuda = throw "Unsupported CUDA version: ${cudaVersion}. Supported versions: ${supportedCudaVersions}";
  platformSources =
    if cudaSupport then systemSources.gpu.${cudaVersion} or throwCuda else systemSources.cpu;

  throwPython = throw "Unsupported python version: ${pyShortVersion}";
  hash = platformSources.${pyShortVersion} or throwPython;

  platform = sources.${stdenv.hostPlatform.system}.platform;

  src =
    if cudaSupport then
      (fetchurl {
        url = "https://paddle-whl.bj.bcebos.com/stable/cu${
          lib.replaceStrings [ "." ] [ "" ] cudaPackages.cudatoolkit.version
        }/paddlepaddle-gpu/paddlepaddle_gpu-${version}-${pyShortVersion}-${pyShortVersion}-linux_x86_64.whl";
        url = "https://paddle-whl.bj.bcebos.com/stable/${cudaVersion}/paddlepaddle-gpu/paddlepaddle_gpu-${version}-${pyShortVersion}-${pyShortVersion}-linux_x86_64.whl";
        inherit hash;
      })
    else