Skip to content

rocmPackages.hiprt: init at 2.5.a21e075.3#411736

Merged
JohnRTitor merged 1 commit intoNixOS:masterfrom
mksafavi:rocmPacakges.hiprt
Aug 10, 2025
Merged

rocmPackages.hiprt: init at 2.5.a21e075.3#411736
JohnRTitor merged 1 commit intoNixOS:masterfrom
mksafavi:rocmPacakges.hiprt

Conversation

@mksafavi
Copy link
Member

@mksafavi mksafavi commented May 28, 2025

Things done

There's a package request (#407646) for adding hip-rt which is needed in blender-hip.
So far I got it to compile but I don't know how to test it.
Building with unittests fail btw, but I didn't examine it further.

I don't really know much about rocm. So if anyone from @NixOS/rocm-maintainers wants to take over let me know.

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • Nixpkgs 25.11 Release Notes (or backporting 24.11 and 25.05 Nixpkgs Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
  • NixOS 25.11 Release Notes (or backporting 24.11 and 25.05 NixOS Release notes)
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added the 6.topic: rocm ROCm is an Advanced Micro Devices software stack for graphics processing unit programming. label May 28, 2025
@mksafavi mksafavi force-pushed the rocmPacakges.hiprt branch from 45d31e8 to 7930a85 Compare May 28, 2025 13:58
@github-actions github-actions bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels May 28, 2025
@mksafavi mksafavi requested a review from LunNova May 30, 2025 23:39
@LunNova
Copy link
Member

LunNova commented Jun 1, 2025

So far I got it to compile but I don't know how to test it.

I don't have a desktop system with AMD to test right now, my cards are in headless boxes for ML.

Maybe the reporter of #407646 can help test?

@mksafavi mksafavi force-pushed the rocmPacakges.hiprt branch from 7930a85 to acfbb0a Compare June 1, 2025 12:09
@mksafavi
Copy link
Member Author

mksafavi commented Jun 1, 2025

So far I got it to compile but I don't know how to test it.

I don't have a desktop system with AMD to test right now, my cards are in headless boxes for ML.

Maybe the reporter of #407646 can help test?

Blender-hip is still broken (#410748) for me so I can't check it with that.

So I thought maybe I should try running some of the hiprt examples with this: https://github.com/GPUOpen-LibrariesAndSDKs/HIPRTSDK

HIPRT build puts the library files in $out/bin. I moved them to $out/lib in postInstall.
With that change, I can compile the HIPRTSDK examples.
But I get a runtime error:

❯ ./dist/bin/Debug/03_custom_intersection64D
Orochi error: '�E' on line 66  in '../common/TutorialBase.cpp'.
❯ ./dist/bin/Debug/00_context_creation64D 
Orochi error: 'mv��' on line 29  in '../00_context_creation/main.cpp'

@mksafavi mksafavi mentioned this pull request Jun 1, 2025
12 tasks
@justinkb
Copy link
Contributor

justinkb commented Jun 3, 2025

I'm seeing issues with the compiled kernels, too, have not tried the examples yet, but it seems like a lot of kernels aren't compiled (the filesizes produced of the hipfb files are way too small).

@justinkb
Copy link
Contributor

justinkb commented Jun 5, 2025

if you add the /lib subdirectory of the rocmPackages.clr derivation to LD_LIBRARY_PATH, the examples seem to work. Still working to see what the deal is with the sizes of those hipfb and bc files, how big are they for you?

@mksafavi
Copy link
Member Author

mksafavi commented Jun 5, 2025

Still working to see what the deal is with the sizes of those hipfb and bc files, how big are they for you?

Thanks for pointing out the file names. The cmake install didn't copy the bc file. It was next to some python scripts. copying it to the build output fixed the runtime issues that I had.

File sizes are around 1.1MBs with BITCODE=ON.
I also tried BAKE_COMPILED_KERNEL=ON. With that the .so file was around 1.5MBs but I couldn't get the examples to run.

./lib:
total 2800
-r--r--r-- 12 root root  609895 Jan  1  1970 hiprt02005_6.3_amd.hipfb
-r--r--r--  2 root root 1111019 Jan  1  1970 hiprt02005_6.3_amd_lib_linux.bc
-r-xr-xr-x 10 root root 1050176 Jan  1  1970 libhiprt0200564.so*
-r--r--r-- 12 root root   89922 Jan  1  1970 oro_compiled_kernels.hipfb

if you add the /lib subdirectory of the rocmPackages.clr derivation to LD_LIBRARY_PATH, the examples seem to work.

Adding clr/lib to library path solved that issue. 👍

hiprt ver.02005
Executing on 'AMD Radeon RX 6800 XT'
In file included from /tmp/nix-shell-47955-0/comgr-67b6cf/input/../common/TutorialKernels.h:23:
../common/Aabb.h:24:10: fatal error: 'hiprt/hiprt_types.h' file not found
   24 | #include <hiprt/hiprt_types.h>
      |          ^~~~~~~~~~~~~~~~~~~~~
1 error generated when compiling for gfx1030.

After adding the hiprt include directory:

hiprt ver.02005
Executing on 'AMD Radeon RX 6800 XT'
orortcLinkAddFile FAILED (error=2) loading file: /nix/store/xjn8gydp3nm8pg57lp9435xdgbd0i8q9-hiprt-2.5.a21e075.3/lib/hiprt02005_6.3_amd_lib_linux.bc
Orortc error: 'HIPRTC_ERROR_PROGRAM_CREATION_FAILURE' [ 2 ] on line 407 in '/build/source/hiprt/impl/Compiler.cpp'.HIPRT error: '2' on line 224  in '../common/TutorialBase.cpp'.

Now I just realized that bc file isn't there. 😅 /nix/store/xjn8gydp3nm8pg57lp9435xdgbd0i8q9-hiprt-2.5.a21e075.3/lib/hiprt02005_6.3_amd_lib_linux.bc

I ran the first 5 examples and the images are the same as the demo one, so I think it's working now.

@justinkb
Copy link
Contributor

justinkb commented Jun 5, 2025

I think our bitcode files are much smaller than for example arch and fedora because we're using some kind of newer offload bundler compression in our tree. Not sure. I got all examples working too. I just passed -DNO_ENCRYPT=ON to cmake to avoid rebuilding that tool (fedora also does this) needed for encryption, and to avoid the gcc nativeBuildInput. I also added a gpuTargets parameter, and a postPatch section that patches the python scripts to honor that setting. I can submit PR for that separately once this is merged though

@mksafavi mksafavi force-pushed the rocmPacakges.hiprt branch from fbd469d to 739400a Compare June 5, 2025 18:31
@justinkb
Copy link
Contributor

justinkb commented Jun 5, 2025

I think it's probably better not to hardcode that filename in the install command in postInstall, since if we move to rocm 6.4.0, then this will start failing without anything having changed with hiprt itself. Also I think you should add a command to symlink libhiprt0200564.so as libhiprt64.so (probably also taking care to futureproof it so that renaming step doesn't need to be updated everytime they end up changing whatever "02005" signifies in that filename. Also I think you should put rocmPackages.clr in buildInputs, then you can remove the HIP_PATH cmake flag, since it'll pick it up automatically from the environment variable that rocmPackages.clr exports

@mksafavi
Copy link
Member Author

mksafavi commented Jun 5, 2025

I think it's probably better not to hardcode that filename in the install command in postInstall, since if we move to rocm 6.4.0, then this will start failing without anything having changed with hiprt itself. Also I think you should add a command to symlink libhiprt0200564.so as libhiprt64.so (probably also taking care to futureproof it so that renaming step doesn't need to be updated everytime they end up changing whatever "02005" signifies in that filename.

Sure 👍
Do you think a simple wildcard like this is enough?

    ln -sr $out/lib/libhiprt*64.so $out/lib/libhiprt64.so
    install -v -Dm644 ../scripts/bitcodes/hiprt*_amd_lib_linux.bc $out/lib/

Also I think you should put rocmPackages.clr in buildInputs, then you can remove the HIP_PATH cmake flag, since it'll pick it up automatically from the environment variable that rocmPackages.clr exports

I removed the HIP_PATH while keeping clr in nativeBuildInputs and it still worked. 🤔

@mksafavi mksafavi force-pushed the rocmPacakges.hiprt branch from 739400a to a9d9194 Compare June 6, 2025 12:12
@mksafavi mksafavi requested a review from mschwaig June 7, 2025 12:59
@mksafavi
Copy link
Member Author

mksafavi commented Jun 7, 2025

Hi @justinkb
Did you try blender with hip-rt? I built it with hip-rt but it crashes when you switch the render engine.
but I suppose we should discuss this in a separate PR?

@justinkb
Copy link
Contributor

justinkb commented Jun 7, 2025 via email

@mksafavi
Copy link
Member Author

Hi.
Is there anything needed to merge this?

@mksafavi mksafavi requested a review from Aleksanaa June 12, 2025 06:21
@justinkb
Copy link
Contributor

I think more properly clr should be listed in buildInputs as opposed to nativeBuildInputs, if I look at how other similar derivations specify their dependencies

@mksafavi mksafavi requested a review from Flakebi June 25, 2025 21:39
@Flakebi
Copy link
Member

Flakebi commented Jun 26, 2025

I think more properly clr should be listed in buildInputs as opposed to nativeBuildInputs

I agree, it should be a runtime dependency :)

@mksafavi mksafavi force-pushed the rocmPacakges.hiprt branch from a9d9194 to 6efc5ad Compare June 27, 2025 08:39
@LunNova
Copy link
Member

LunNova commented Jun 28, 2025

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 411736
Commit: 6efc5ad5e164368b6572443bda8a53cc1a2c4dbe


x86_64-linux

✅ 1 package built:
  • rocmPackages.hiprt (rocmPackages_6.hiprt)

@nixpkgs-ci nixpkgs-ci bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Jun 28, 2025
@mksafavi mksafavi requested a review from LunNova July 5, 2025 13:13
@mksafavi
Copy link
Member Author

Hi.
Is there anything needed to merge this?

@LunNova
Copy link
Member

LunNova commented Jul 30, 2025

Approved, I don't have merge perms.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/5723

@JohnRTitor JohnRTitor merged commit 5adc3ad into NixOS:master Aug 10, 2025
28 checks passed
@JohnRTitor
Copy link
Member

JohnRTitor commented Aug 10, 2025

I don't have merge perms

You can apply to be a commiter or ping one you know/have interacted with.

@mksafavi mksafavi deleted the rocmPacakges.hiprt branch September 15, 2025 14:30
@mksafavi mksafavi restored the rocmPacakges.hiprt branch September 15, 2025 14:31
@mksafavi mksafavi deleted the rocmPacakges.hiprt branch September 15, 2025 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: rocm ROCm is an Advanced Micro Devices software stack for graphics processing unit programming. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants