pytorch - 💡(How to fix) Fix HIP related errors compiling against PyTorch [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
pytorch/pytorch#181939Fetched 2026-04-30 06:17:42
View on GitHub
Comments
0
Participants
1
Timeline
62
Reactions
0
Author
Participants
Timeline (top)
mentioned ×28subscribed ×28labeled ×5added_to_project_v2 ×1

Error Message

/usr/bin/ld: cannot find -lMIOpen: No such file or directory /usr/bin/ld: cannot find -lhiprtc::hiprtc: No such file or directory /usr/bin/ld: cannot find -lroc::hipblas: No such file or directory /usr/bin/ld: cannot find -lroc::rocblas: No such file or directory /usr/bin/ld: cannot find -lhip::hipfft: No such file or directory /usr/bin/ld: cannot find -lhip::hiprand: No such file or directory /usr/bin/ld: cannot find -lroc::hipsparse: No such file or directory /usr/bin/ld: cannot find -lroc::hipsolver: No such file or directory /usr/bin/ld: cannot find -lroc::hipblaslt: No such file or directory /usr/bin/ld: cannot find -lroc::rocsolver: No such file or directory /usr/bin/ld: cannot find -lroc::hipsparselt: No such file or directory collect2: error: ld returned 1 exit status

Code Example

pip install torch --index-url https://download.pytorch.org/whl/rocm7.2

---

FIND_PACKAGE(Torch REQUIRED)

---

Building PyTorch for GPU arch: gfx1036;gfx1201
-- Could NOT find HIP: Found unsuitable version "0.0.0", but required is at least "1.0" (found /opt/rocm-7.2.1)
Optional package HIP not found

---

/usr/bin/ld: cannot find -lMIOpen: No such file or directory
/usr/bin/ld: cannot find -lhiprtc::hiprtc: No such file or directory
/usr/bin/ld: cannot find -lroc::hipblas: No such file or directory
/usr/bin/ld: cannot find -lroc::rocblas: No such file or directory
/usr/bin/ld: cannot find -lhip::hipfft: No such file or directory
/usr/bin/ld: cannot find -lhip::hiprand: No such file or directory
/usr/bin/ld: cannot find -lroc::hipsparse: No such file or directory
/usr/bin/ld: cannot find -lroc::hipsolver: No such file or directory
/usr/bin/ld: cannot find -lroc::hipblaslt: No such file or directory
/usr/bin/ld: cannot find -lroc::rocsolver: No such file or directory
/usr/bin/ld: cannot find -lroc::hipsparselt: No such file or directory
collect2: error: ld returned 1 exit status
RAW_BUFFERClick to expand / collapse

I'm trying to compile a C++ program that links to PyTorch. I'm on Linux and using PyTorch 2.11. My computer has an AMD GPU, and I have ROCm 7.2.1 installed in /opt/rocm-7.2.1. I installed PyTorch by following the instructions at https://pytorch.org/get-started/locally/:

pip install torch --index-url https://download.pytorch.org/whl/rocm7.2

I use CMake as the build system. When it reaches the following line in my build script

FIND_PACKAGE(Torch REQUIRED)

it prints the message

Building PyTorch for GPU arch: gfx1036;gfx1201
-- Could NOT find HIP: Found unsuitable version "0.0.0", but required is at least "1.0" (found /opt/rocm-7.2.1)
Optional package HIP not found

I'm not sure what to make of that. It identified where HIP is installed, but then said it couldn't find it? When it then tries to compile my program, which links to libtorch, it produces lots of errors:

/usr/bin/ld: cannot find -lMIOpen: No such file or directory
/usr/bin/ld: cannot find -lhiprtc::hiprtc: No such file or directory
/usr/bin/ld: cannot find -lroc::hipblas: No such file or directory
/usr/bin/ld: cannot find -lroc::rocblas: No such file or directory
/usr/bin/ld: cannot find -lhip::hipfft: No such file or directory
/usr/bin/ld: cannot find -lhip::hiprand: No such file or directory
/usr/bin/ld: cannot find -lroc::hipsparse: No such file or directory
/usr/bin/ld: cannot find -lroc::hipsolver: No such file or directory
/usr/bin/ld: cannot find -lroc::hipblaslt: No such file or directory
/usr/bin/ld: cannot find -lroc::rocsolver: No such file or directory
/usr/bin/ld: cannot find -lroc::hipsparselt: No such file or directory
collect2: error: ld returned 1 exit status

My program does not link to those libraries directly, just to libtorch. All of them are present in /opt/rocm-7.2.1/lib.

What could be causing the problem, and what do I need to do to fix it?

cc @malfet @seemethere @jbschlosser @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @jataylo @hongxiayang @naromero77amd @pragupta @jerrymannil @xinyazhang

extent analysis

TL;DR

The issue is likely due to the linker not being able to find the required libraries, which are present in /opt/rocm-7.2.1/lib, and can be fixed by updating the library path.

Guidance

  • Verify that the HIP_HOME environment variable is set to /opt/rocm-7.2.1 before running CMake.
  • Check the CMakeLists.txt file to ensure that the library path is correctly set to include /opt/rocm-7.2.1/lib.
  • Use the link_directories command in CMake to add the /opt/rocm-7.2.1/lib directory to the linker search path.
  • Confirm that the required libraries (e.g. libMIOpen, libhiprtc, etc.) are present in /opt/rocm-7.2.1/lib and have the correct permissions.

Example

set(ENV{HIP_HOME} /opt/rocm-7.2.1)
link_directories(/opt/rocm-7.2.1/lib)

Notes

The issue may be specific to the ROCm version or the PyTorch installation. If the problem persists, try checking the PyTorch documentation for any specific requirements or recommendations for using ROCm.

Recommendation

Apply workaround: Update the library path and environment variables to ensure the linker can find the required libraries. This is likely to resolve the issue without requiring a version upgrade.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING