ROCm/ROCm-Device-Libs

AMDDeviceLibsConfig.cmake could not be found by HIP

Closed this issue · 5 comments

In CMake project, when doing find_package(HIP REQUIRED) the line find_dependency(AMDDeviceLibs) of /opt/rocm-5.1.0/hip/lib/cmake/hip/hip-config.cmake fails to find AMDDeviceLibsConfig.cmake. The AMDDeviceLibsConfig.cmake.in clearly indicates that the file should present, but perhaps was lost during release packaging. The file is present in /opt//rocm-5.1.0/lib/cmake/AMDDeviceLibs/AMDDeviceLibsConfig.cmake, but could not be found by HIP.

I just now verified 5.1.0 release packages and confirmed "AMDDeviceLibsConfig.cmake" is indeed present in the pacakge.

#############################################
dpkg -c rocm-device-libs_1.0.0.50100-36_amd64.deb
.....
./opt/rocm-5.1.0/lib/cmake/AMDDeviceLibs/AMDDeviceLibsConfig.cmake
.....
##########################################################

Can you please share the full log of what you see as error?

cmake .. -G Ninja
CMake Error at /usr/share/cmake-3.23/Modules/CMakeFindDependencyMacro.cmake:47 (find_package):
  By not providing "FindAMDDeviceLibs.cmake" in CMAKE_MODULE_PATH this
  project has asked CMake to find a package configuration file provided by
  "AMDDeviceLibs", but CMake did not find one.

  Could not find a package configuration file provided by "AMDDeviceLibs"
  with any of the following names:

    AMDDeviceLibsConfig.cmake
    amddevicelibs-config.cmake

  Add the installation prefix of "AMDDeviceLibs" to CMAKE_PREFIX_PATH or set
  "AMDDeviceLibs_DIR" to a directory containing one of the above files.  If
  "AMDDeviceLibs" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  /opt/rocm/hip/lib/cmake/hip/hip-config.cmake:187 (find_dependency)
  CMakeLists.txt:49 (find_package)


-- Configuring incomplete, errors occurred!

I was confused by the fact that apt-file search AMDDeviceLibsConfig.cmake command gives empty result. Indeed, /opt/rocm-5.1.0/lib/cmake/AMDDeviceLibs/AMDDeviceLibsConfig.cmake does exist, but hip-config.cmake is not able to locate it. Shall we always add CMAKE_MODULE_PATH or CMAKE_PREFIX_PATH to all rocm components manually?

I was able to resolve the issue by following exactly this example in the guide mentioned in ROCm/HIP#955:

if(NOT DEFINED HIP_PATH)
    if(NOT DEFINED ENV{HIP_PATH})
        set(HIP_PATH "/opt/rocm/hip" CACHE PATH "Path to which HIP has been installed")
    else()
        set(HIP_PATH $ENV{HIP_PATH} CACHE PATH "Path to which HIP has been installed")
    endif()
endif()
set(CMAKE_MODULE_PATH "${HIP_PATH}/cmake" ${CMAKE_MODULE_PATH})
find_package(HIP)

Thanks!

Thanks for the update. We will look into why apt-file search was not finding the file.