2024-06-05 15:53:02 +00:00
|
|
|
|
{
|
|
|
|
|
stdenv,
|
|
|
|
|
config,
|
|
|
|
|
lib,
|
|
|
|
|
buildPythonPackage,
|
|
|
|
|
fetchPypi,
|
|
|
|
|
python,
|
|
|
|
|
pythonOlder,
|
|
|
|
|
pythonAtLeast,
|
|
|
|
|
openssl_1_1,
|
|
|
|
|
zlib,
|
|
|
|
|
setuptools,
|
|
|
|
|
cudaSupport ? config.cudaSupport or false,
|
|
|
|
|
cudaPackages_11 ? { },
|
|
|
|
|
addOpenGLRunpath,
|
|
|
|
|
# runtime dependencies
|
|
|
|
|
httpx,
|
|
|
|
|
numpy,
|
|
|
|
|
protobuf,
|
|
|
|
|
pillow,
|
|
|
|
|
decorator,
|
|
|
|
|
astor,
|
|
|
|
|
paddle-bfloat,
|
|
|
|
|
opt-einsum,
|
2023-08-22 20:05:09 +00:00
|
|
|
|
}:
|
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
pname = "paddlepaddle" + lib.optionalString cudaSupport "-gpu";
|
|
|
|
|
version = "2.5.0";
|
|
|
|
|
format = "wheel";
|
2024-06-05 15:53:02 +00:00
|
|
|
|
pyShortVersion = "cp${builtins.replaceStrings [ "." ] [ "" ] python.pythonVersion}";
|
2024-01-13 08:15:51 +00:00
|
|
|
|
cpuOrGpu = if cudaSupport then "gpu" else "cpu";
|
2023-08-22 20:05:09 +00:00
|
|
|
|
allHashAndPlatform = import ./binary-hashes.nix;
|
2024-06-05 15:53:02 +00:00
|
|
|
|
hash =
|
|
|
|
|
allHashAndPlatform."${stdenv.system}"."${cpuOrGpu}"."${pyShortVersion}"
|
|
|
|
|
or (throw "${pname} has no binary-hashes.nix entry for '${stdenv.system}.${cpuOrGpu}.${pyShortVersion}' attribute");
|
2023-08-22 20:05:09 +00:00
|
|
|
|
platform = allHashAndPlatform."${stdenv.system}".platform;
|
|
|
|
|
src = fetchPypi ({
|
2024-06-05 15:53:02 +00:00
|
|
|
|
inherit
|
|
|
|
|
version
|
|
|
|
|
format
|
|
|
|
|
hash
|
|
|
|
|
platform
|
|
|
|
|
;
|
2023-08-22 20:05:09 +00:00
|
|
|
|
pname = builtins.replaceStrings [ "-" ] [ "_" ] pname;
|
|
|
|
|
dist = pyShortVersion;
|
|
|
|
|
python = pyShortVersion;
|
|
|
|
|
abi = pyShortVersion;
|
|
|
|
|
});
|
|
|
|
|
in
|
|
|
|
|
buildPythonPackage {
|
2024-06-05 15:53:02 +00:00
|
|
|
|
inherit
|
|
|
|
|
pname
|
|
|
|
|
version
|
|
|
|
|
format
|
|
|
|
|
src
|
|
|
|
|
;
|
2023-08-22 20:05:09 +00:00
|
|
|
|
|
|
|
|
|
disabled = pythonOlder "3.9" || pythonAtLeast "3.11";
|
|
|
|
|
|
|
|
|
|
libraryPath = lib.makeLibraryPath (
|
|
|
|
|
# TODO: remove openssl_1_1 and zlib, maybe by building paddlepaddle from
|
|
|
|
|
# source as suggested in the following comment:
|
|
|
|
|
# https://github.com/NixOS/nixpkgs/pull/243583#issuecomment-1641450848
|
2024-06-05 15:53:02 +00:00
|
|
|
|
[
|
|
|
|
|
openssl_1_1
|
|
|
|
|
zlib
|
|
|
|
|
]
|
|
|
|
|
++ lib.optionals cudaSupport (
|
|
|
|
|
with cudaPackages_11;
|
|
|
|
|
[
|
|
|
|
|
cudatoolkit.lib
|
|
|
|
|
cudatoolkit.out
|
|
|
|
|
cudnn
|
|
|
|
|
]
|
|
|
|
|
)
|
2023-08-22 20:05:09 +00:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
postFixup = lib.optionalString stdenv.isLinux ''
|
|
|
|
|
function fixRunPath {
|
|
|
|
|
p=$(patchelf --print-rpath $1)
|
|
|
|
|
patchelf --set-rpath "$p:$libraryPath" $1
|
|
|
|
|
${lib.optionalString cudaSupport ''
|
|
|
|
|
addOpenGLRunpath $1
|
|
|
|
|
''}
|
|
|
|
|
}
|
|
|
|
|
fixRunPath $out/${python.sitePackages}/paddle/fluid/libpaddle.so
|
|
|
|
|
'';
|
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
|
nativeBuildInputs = [ addOpenGLRunpath ];
|
2023-08-22 20:05:09 +00:00
|
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
|
setuptools
|
|
|
|
|
httpx
|
|
|
|
|
numpy
|
|
|
|
|
protobuf
|
|
|
|
|
pillow
|
|
|
|
|
decorator
|
|
|
|
|
astor
|
|
|
|
|
paddle-bfloat
|
|
|
|
|
opt-einsum
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
pythonImportsCheck = [ "paddle" ];
|
|
|
|
|
|
|
|
|
|
# no tests
|
|
|
|
|
doCheck = false;
|
|
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
|
description = "PArallel Distributed Deep LEarning: Machine Learning Framework from Industrial Practice (『飞桨』核心框架,深度学习&机器学习高性能单机、分布式训练和跨平台部署";
|
|
|
|
|
homepage = "https://github.com/PaddlePaddle/Paddle";
|
|
|
|
|
license = licenses.asl20;
|
|
|
|
|
maintainers = with maintainers; [ happysalada ];
|
2024-06-05 15:53:02 +00:00
|
|
|
|
platforms =
|
|
|
|
|
[ "x86_64-linux" ]
|
|
|
|
|
++ optionals (!cudaSupport) [
|
|
|
|
|
"x86_64-darwin"
|
|
|
|
|
"aarch64-darwin"
|
|
|
|
|
];
|
2023-08-22 20:05:09 +00:00
|
|
|
|
};
|
|
|
|
|
}
|