Skip to content

Commit 91c27f2

Browse files
authored
Hard fail if hipconfig fallback doesn't return version
1 parent d161f0a commit 91c27f2

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

CMakeLists.txt

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -308,14 +308,25 @@ elseif(BUILD_ROCM)
308308
if(NOT _DETECTED_ROCM_VERSION)
309309
execute_process(COMMAND hipconfig --version OUTPUT_VARIABLE HIP_CONFIG_VERSION)
310310
string(REGEX MATCH "[0-9]+\\.[0-9]+" _DETECTED_ROCM_VERSION "${HIP_CONFIG_VERSION}")
311-
message(WARNING
312-
"Could not infer ROCm version from ${_ROCM_ROOT}/.info/version; falling back to hipconfig.\n"
313-
"Starting with ROCm 7.x the HIP SDK version diverges from the ROCm version, "
314-
"which may produce a misnamed library.\n"
315-
"To fix this you can either:\n"
316-
" - At build time: cmake -DROCM_VERSION=<shortcode> (e.g. -DROCM_VERSION=71 for ROCm 7.1)\n"
317-
" - At runtime: export BNB_ROCM_VERSION=<shortcode> (e.g. BNB_ROCM_VERSION=71)"
318-
)
311+
312+
if(_DETECTED_ROCM_VERSION)
313+
message(WARNING
314+
"Could not read ROCm version from ${_ROCM_ROOT}/.info/version; "
315+
"falling back to hipconfig (${_DETECTED_ROCM_VERSION}).\n"
316+
"Starting with ROCm 7.x the HIP SDK version diverges from the ROCm version, "
317+
"which may produce a misnamed library.\n"
318+
"To fix this you can either:\n"
319+
" - At build time: cmake -DROCM_VERSION=<shortcode> (e.g. -DROCM_VERSION=71 for ROCm 7.1)\n"
320+
" - At runtime: export BNB_ROCM_VERSION=<shortcode> (e.g. BNB_ROCM_VERSION=71)"
321+
)
322+
else()
323+
message(FATAL_ERROR
324+
"Could not detect the ROCm version.\n"
325+
"Checked:\n"
326+
" 1. ${_ROCM_ROOT}/.info/version — not found or not readable\n"
327+
" 2. hipconfig --version — not found or returned no version\n"
328+
"Please install ROCm and ensure ROCM_PATH is set correctly, or\n"
329+
)
319330
endif()
320331

321332
string(REPLACE "." "" _DETECTED_ROCM_VERSION_SHORT "${_DETECTED_ROCM_VERSION}")

0 commit comments

Comments
 (0)