From f33f2a84f8c846bd90afb3ee4b3f99e6e3840950 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Fri, 13 Jun 2025 14:27:15 +0200 Subject: [PATCH 1/2] python3Packages.onnxruntime: mark as broken on aarch64-linux --- pkgs/development/python-modules/onnxruntime/default.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkgs/development/python-modules/onnxruntime/default.nix b/pkgs/development/python-modules/onnxruntime/default.nix index 1de9d7d92c429..1621468da0848 100644 --- a/pkgs/development/python-modules/onnxruntime/default.nix +++ b/pkgs/development/python-modules/onnxruntime/default.nix @@ -79,5 +79,12 @@ buildPythonPackage { # sympy ]; - meta = onnxruntime.meta; + meta = onnxruntime.meta // { + badPlatforms = (onnxruntime.meta.badPlatforms or [ ]) ++ [ + # Many downstream packages (vectorcode for e.g.) crash when importing `onnxruntime`: + # in onnxruntime/capi/_pybind_state.py + # Fatal Python error: Aborted + "aarch64-linux" + ]; + }; } From c4d9d7f8935b5a0cc857429ff0372bfba9644264 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sun, 15 Jun 2025 16:21:33 +0200 Subject: [PATCH 2/2] wip --- .../on/onnxruntime/fix-cpuinfo-logging.patch | 27 +++++++++++++++++++ pkgs/by-name/on/onnxruntime/package.nix | 3 +++ .../python-modules/onnxruntime/default.nix | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 pkgs/by-name/on/onnxruntime/fix-cpuinfo-logging.patch diff --git a/pkgs/by-name/on/onnxruntime/fix-cpuinfo-logging.patch b/pkgs/by-name/on/onnxruntime/fix-cpuinfo-logging.patch new file mode 100644 index 0000000000000..f8039fb5f43ba --- /dev/null +++ b/pkgs/by-name/on/onnxruntime/fix-cpuinfo-logging.patch @@ -0,0 +1,27 @@ +diff --git a/onnxruntime/core/common/cpuid_info.cc b/onnxruntime/core/common/cpuid_info.cc +index 91961bf22c..2f742ad971 100644 +--- a/onnxruntime/core/common/cpuid_info.cc ++++ b/onnxruntime/core/common/cpuid_info.cc +@@ -3,6 +3,7 @@ + #include "core/common/cpuid_info.h" + #include "core/common/logging/logging.h" + #include "core/common/logging/severity.h" ++#include + + #ifdef __linux__ + +@@ -364,8 +365,12 @@ CPUIDInfo::CPUIDInfo() { + #if defined(CPUINFO_SUPPORTED) + pytorch_cpuinfo_init_ = cpuinfo_initialize(); + if (!pytorch_cpuinfo_init_) { +- LOGS_DEFAULT(WARNING) << "Failed to initialize PyTorch cpuinfo library. May cause CPU EP performance degradation " +- "due to undetected CPU features."; ++ constexpr const char* message = "Failed to init pytorch cpuinfo library, may cause CPU EP performance degradation due to undetected CPU features."; ++ if (logging::LoggingManager::HasDefaultLogger()) { ++ LOGS_DEFAULT(WARNING) << message; ++ } else { ++ std::cerr << message << std::endl; ++ } + } + #endif // defined(CPUINFO_SUPPORTED) + #if defined(__linux__) diff --git a/pkgs/by-name/on/onnxruntime/package.nix b/pkgs/by-name/on/onnxruntime/package.nix index 4dfa54fd52ede..3078ec95e8bea 100644 --- a/pkgs/by-name/on/onnxruntime/package.nix +++ b/pkgs/by-name/on/onnxruntime/package.nix @@ -108,6 +108,9 @@ effectiveStdenv.mkDerivation rec { # We apply the referenced 1064.patch ourselves to our nix dependency. # FIND_PACKAGE_ARGS for CUDA was added in https://github.com/microsoft/onnxruntime/commit/87744e5 so it might be possible to delete this patch after upgrading to 1.17.0 ./nvcc-gsl.patch + + # https://github.com/microsoft/onnxruntime/pull/15661 + ./fix-cpuinfo-logging.patch ]; nativeBuildInputs = diff --git a/pkgs/development/python-modules/onnxruntime/default.nix b/pkgs/development/python-modules/onnxruntime/default.nix index 1621468da0848..c2200874212fe 100644 --- a/pkgs/development/python-modules/onnxruntime/default.nix +++ b/pkgs/development/python-modules/onnxruntime/default.nix @@ -84,7 +84,7 @@ buildPythonPackage { # Many downstream packages (vectorcode for e.g.) crash when importing `onnxruntime`: # in onnxruntime/capi/_pybind_state.py # Fatal Python error: Aborted - "aarch64-linux" + # "aarch64-linux" ]; }; }