Skip to content

Commit 26f6990

Browse files
works
1 parent 60f99e8 commit 26f6990

File tree

4 files changed

+41
-25
lines changed

4 files changed

+41
-25
lines changed

desktop/l/custom-packages/onnxruntime/package.nix

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
, stdenv
33
, lib
44
, fetchFromGitHub
5-
, abseil-cpp_202508
5+
, abseil-cpp_202407
66
, cmake
77
, cpuinfo
88
, eigen
9-
, flatbuffers
9+
, flatbuffers_23
1010
, glibcLocales
1111
, gtest
1212
, howard-hinnant-date
@@ -49,21 +49,21 @@ let
4949
owner = "boostorg";
5050
repo = "mp11";
5151
tag = "boost-1.89.0";
52-
hash = "sha256-6dbfae01358be88ebefcdfb7707a2a68ba914c39dc83fdd85f556761fe0fafb4";
52+
hash = "sha256-HcQJ/PXBQdWVjGZy28X2LxVRfjV2nkeLTusNjT9ssXI=";
5353
};
5454

5555
safeint = fetchFromGitHub {
5656
owner = "dcleblanc";
5757
repo = "safeint";
5858
tag = "3.0.28a";
59-
hash = "sha256-9e652d065a3cef80623287d5dc61edcf6a95ddab38a9dfeb34f155261fc9cef7";
59+
hash = "sha256-MT2nba15DDApNQZxOBkf0DPvc759rEhpwfcD6ERphl0=";
6060
};
6161

6262
onnx = fetchFromGitHub {
6363
owner = "onnx";
6464
repo = "onnx";
65-
tag = "v1.19.0";
66-
hash = "sha256-2c2ac5a078b0350a0723fac606be8cd9e9e8cbd4c99bab1bffe2623b188fd236";
65+
tag = "v1.17.0";
66+
hash = "sha256-9oORW0YlQ6SphqfbjcYb0dTlHc+1gzy9quH/Lj6By8Q=";
6767
};
6868

6969
cutlass = fetchFromGitHub {
@@ -77,7 +77,7 @@ let
7777
owner = "dmlc";
7878
repo = "dlpack";
7979
tag = "v1.1";
80-
hash = "sha256-2e3b94b55825c240cc58e6721e15b449978cbae21a2a4caa23058b0157ee2fb3";
80+
hash = "sha256-RoJxvlrt1QcGvB8m/kycziTbO367diOpsnro49hDl24=";
8181
};
8282

8383
isCudaJetson = cudaSupport && cudaPackages.flags.isJetsonBuild;
@@ -118,6 +118,8 @@ effectiveStdenv.mkDerivation rec {
118118
++ lib.optionals rocmSupport [
119119
rocmPackages.rocm-cmake
120120
rocmPackages.hipcc
121+
rocmPackages.llvm.clang
122+
rocmPackages.rocm-device-libs
121123
];
122124

123125
buildInputs = [
@@ -205,9 +207,9 @@ effectiveStdenv.mkDerivation rec {
205207
(lib.cmakeBool "ABSL_ENABLE_INSTALL" true)
206208
(lib.cmakeBool "FETCHCONTENT_FULLY_DISCONNECTED" true)
207209
(lib.cmakeBool "FETCHCONTENT_QUIET" false)
208-
(lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_ABSEIL_CPP" "${abseil-cpp_202508.src}")
210+
(lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_ABSEIL_CPP" "${abseil-cpp_202407.src}")
209211
(lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_DLPACK" "${dlpack}")
210-
(lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_FLATBUFFERS" "${flatbuffers.src}")
212+
(lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_FLATBUFFERS" "${flatbuffers_23.src}")
211213
(lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_MP11" "${mp11}")
212214
(lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_ONNX" "${onnx}")
213215
(lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_RE2" "${re2.src}")
@@ -245,6 +247,17 @@ effectiveStdenv.mkDerivation rec {
245247

246248
env = lib.optionalAttrs effectiveStdenv.cc.isClang {
247249
NIX_CFLAGS_COMPILE = "-Wno-error";
250+
} // lib.optionalAttrs rocmSupport {
251+
# ROCm environment variables for HIP compiler
252+
ROCM_PATH = "${rocmPackages.rocm-core}";
253+
HIP_PATH = "${rocmPackages.hipcc}";
254+
HIP_CLANG_PATH = "${rocmPackages.llvm.clang}/bin";
255+
HSA_PATH = "${rocmPackages.rocm-core}";
256+
HIP_PLATFORM = "amd";
257+
HIP_COMPILER = "clang";
258+
HIP_RUNTIME = "rocclr";
259+
# ROCm device library path
260+
ROCM_DEVICE_LIB_PATH = "${rocmPackages.rocm-device-libs}/lib";
248261
};
249262

250263
doCheck =
@@ -280,6 +293,16 @@ effectiveStdenv.mkDerivation rec {
280293
rm -v onnxruntime/test/optimizer/nhwc_transformer_test.cc
281294
'';
282295

296+
preConfigure = lib.optionalString rocmSupport ''
297+
# Create symlinks for ROCm tools that HIP compiler expects
298+
mkdir -p /tmp/rocm/bin /tmp/rocm/lib/llvm/bin
299+
ln -sf ${rocmPackages.rocm-core}/bin/rocm_agent_enumerator /tmp/rocm/bin/rocm_agent_enumerator
300+
ln -sf ${rocmPackages.llvm.clang}/bin/clang++ /tmp/rocm/lib/llvm/bin/clang++
301+
ln -sf ${rocmPackages.llvm.clang}/bin/clang /tmp/rocm/lib/llvm/bin/clang
302+
export ROCM_PATH=/tmp/rocm
303+
export ROCM_DEVICE_LIB_PATH=${rocmPackages.rocm-device-libs}/lib
304+
'';
305+
283306
postBuild = lib.optionalString pythonSupport ''
284307
${python3Packages.python.interpreter} ../setup.py bdist_wheel
285308
'';

desktop/l/custom-packages/python-onnxruntime/default.nix

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ buildPythonPackage {
5959
# Same applies to ROCm support - the Python package inherits ROCm support from the core package.
6060
onnxruntime
6161
]
62-
++ lib.optionals onnxruntime.passthru.cudaSupport (
62+
# Note: CUDA and ROCm support dependencies are handled by the core onnxruntime package
63+
# The Python package inherits the same capabilities through the shared libraries
64+
++ lib.optionals (onnxruntime ? passthru && onnxruntime.passthru ? cudaSupport && onnxruntime.passthru.cudaSupport) (
6365
with onnxruntime.passthru.cudaPackages;
6466
[
6567
libcublas # libcublasLt.so.XX libcublas.so.XX
@@ -70,7 +72,7 @@ buildPythonPackage {
7072
nccl # libnccl.so.XX
7173
]
7274
)
73-
++ lib.optionals onnxruntime.passthru.rocmSupport (
75+
++ lib.optionals (onnxruntime ? passthru && onnxruntime.passthru ? rocmSupport && onnxruntime.passthru.rocmSupport) (
7476
with onnxruntime.passthru.rocmPackages;
7577
[
7678
rocm-core # ROCm core libraries

desktop/l/flake.nix

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,11 @@
5353
# Apply the overlay to NixOS
5454
nixpkgs.overlays = [
5555
(final: prev: {
56+
# Custom onnxruntime with ROCm support (temporarily disabled)
5657
onnxruntime = final.callPackage ./custom-packages/onnxruntime/package.nix {
57-
rocmSupport = true;
58-
rcclSupport = true;
58+
rocmSupport = false;
59+
rcclSupport = false;
5960
};
60-
python313Packages = prev.python313Packages.override (old: {
61-
overrides = prev.lib.composeManyExtensions [
62-
(final: prev: {
63-
onnxruntime = final.callPackage ./custom-packages/python-onnxruntime/default.nix {
64-
onnxruntime = final.onnxruntime;
65-
};
66-
})
67-
old.overrides or (final: prev: { })
68-
];
69-
});
7061
})
7162
];
7263

desktop/l/home.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,10 +449,10 @@
449449
# Screenshot tool with Wayland support
450450
(flameshot.override { enableWlrSupport = true; })
451451

452-
# Custom onnxruntime package
452+
# Custom onnxruntime package with ROCm support
453453
onnxruntime
454454

455-
# Custom Python onnxruntime module
455+
# Standard Python onnxruntime module (should work with custom C++ library)
456456
python313Packages.onnxruntime
457457
];
458458

0 commit comments

Comments
 (0)