Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 autoPatchelfHook, 6 onnxruntime, 7 coloredlogs, 8 numpy, 9 packaging, 10 oneDNN, 11 re2, 12 13}: 14 15# onnxruntime requires an older protobuf. 16# Doing an override in protobuf in the python-packages set 17# can give you a functioning Python package but note not 18# all Python packages will be compatible then. 19# 20# Because protobuf is not always needed we remove it 21# as a runtime dependency from our wheel. 22# 23# We do include here the non-Python protobuf so the shared libs 24# link correctly. If you do also want to include the Python 25# protobuf, you can add it to your Python env, but be aware 26# the version likely mismatches with what is used here. 27 28buildPythonPackage { 29 inherit (onnxruntime) pname version; 30 format = "wheel"; 31 src = onnxruntime.dist; 32 33 unpackPhase = '' 34 cp -r $src dist 35 chmod +w dist 36 ''; 37 38 nativeBuildInputs = lib.optionals stdenv.isLinux [ autoPatchelfHook ]; 39 40 # This project requires fairly large dependencies such as sympy which we really don't always need. 41 pythonRemoveDeps = [ 42 "flatbuffers" 43 "protobuf" 44 "sympy" 45 ]; 46 47 # Libraries are not linked correctly. 48 buildInputs = 49 [ 50 oneDNN 51 re2 52 onnxruntime.protobuf 53 ] 54 ++ lib.optionals onnxruntime.passthru.cudaSupport ( 55 with onnxruntime.passthru.cudaPackages; 56 [ 57 libcublas # libcublasLt.so.XX libcublas.so.XX 58 libcurand # libcurand.so.XX 59 libcufft # libcufft.so.XX 60 cudnn # libcudnn.soXX 61 cuda_cudart # libcudart.so.XX 62 nccl # libnccl.so.XX 63 ] 64 ); 65 66 propagatedBuildInputs = [ 67 coloredlogs 68 # flatbuffers 69 numpy 70 packaging 71 # protobuf 72 # sympy 73 ]; 74 75 meta = onnxruntime.meta; 76}