CMAKE_HIP_COMPILER_ROCM_ROOT is not set correctly

Hi, I’m trying to build composable-kernel-6.2.4 and I’ve got cmake 3.31.0 installed.
It is looking into CMakeDetermineHIPCompiler.cmake and trying to get a parameter called CMAKE_HIP_COMPILER_ROCM_ROOT from it but fails with this error:

CMake Error at /usr/share/cmake/Modules/CMakeDetermineHIPCompiler.cmake:217 (message):
  The ROCm root directory:

   /usr/lib

  does not contain the HIP runtime CMake package, expected at one of:

   /usr/lib/lib/cmake/hip-lang/hip-lang-config.cmake
   /usr/lib/lib64/cmake/hip-lang/hip-lang-config.cmake

Call Stack (most recent call first):
  CMakeLists.txt:26 (project)

I looked inside that file, and changed the order of the rules to use the last one first as a WA:

if(NOT CMAKE_HIP_COMPILER_ROCM_ROOT)
  execute_process(
    COMMAND hipconfig --rocmpath
    OUTPUT_VARIABLE _CMAKE_HIPCONFIG_ROCMPATH
    RESULT_VARIABLE _CMAKE_HIPCONFIG_RESULT
    )
  if(_CMAKE_HIPCONFIG_RESULT EQUAL 0 AND EXISTS "${_CMAKE_HIPCONFIG_ROCMPATH}")
    set(CMAKE_HIP_COMPILER_ROCM_ROOT "${_CMAKE_HIPCONFIG_ROCMPATH}")
  endif()
endif()
if(NOT CMAKE_HIP_COMPILER_ROCM_ROOT)
  message(FATAL_ERROR "Failed to find ROCm root directory.")
endif()

Works for me with that change, but its probably not the best solution?

@cmyster what is your host distro (e.g., Ubuntu or Fedora), and how was ROCm installed (e.g., distro package or ROCm installer)?

What is the output of hipconfig --rocmpath?

From your quoted code I can’t tell what change you made to get it working. Please clarify.

Thanks Brad, I think I have an issue but I need to see if its a bug or some integration issue.
I am using Gentoo and it has 6.1.1 that works. I was attempting to bring it up to 6.2.4.

hipconfig is not working well for me and I need to see how I can tell it where all the paths are:

hipconfig

Device not supported - Defaulting to AMD (I have AMD)
Hip Clang Compiler not found (I installed that actually)
HIP version: 6.2.41134-0

==hipconfig
HIP_PATH :/usr
ROCM_PATH :/usr
HIP_COMPILER :clang
HIP_PLATFORM :amd
HIP_RUNTIME :rocclr
CPP_CONFIG : -D__HIP_PLATFORM_HCC__= -D__HIP_PLATFORM_AMD__= -I/usr/include -I/include

==hip-clang
HIP_CLANG_PATH :/usr/lib/llvm/bin
sh: line 1: /usr/lib/llvm/bin/clang++: No such file or directory (This is because llvm’s path in Gentoo has a major version, i.e. /usr/lib/llvm/18/bin/clang++ works).
sh: line 1: /usr/lib/llvm/bin/llc: No such file or directory (same)
hip-clang-cxxflags :
Device not supported - Defaulting to AMD
-O3
hip-clang-ldflags :
Device not supported - Defaulting to AMD
–driver-mode=g++ -O3 --hip-link

== Environment Variables
PATH =/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/bin:/usr/lib/llvm/19/bin:/usr/lib/llvm/18/bin

== Linux Kernel
Hostname :
cmyster-pc
Linux cmyster-pc 6.12.0-gentoo #1 SMP PREEMPT_DYNAMIC Wed Nov 20 19:23:10 IST 2024 x86_64 AMD Ryzen 9 5900X 12-Core Processor AuthenticAMD GNU/Linux
LSB Version: n/a
Distributor ID: Gentoo
Description: Gentoo Linux
Release: 2.17
Codename: n/a

I’ll try my luck fixing that first, Gentoo installs this executable as part of a hipcc package, so I need to see how to change it such that it can guess the paths better.