Skip to content

Commit 36f944a

Browse files
author
root
committed
This extra code removes the trailing hashcode from the HIP_VERSION variable so that the torch.version.hip is parsable by packaging version parse method.
1 parent a6df8f0 commit 36f944a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

cmake/public/LoadHIP.cmake

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,17 @@ if(HIP_FOUND)
8484
set(PYTORCH_FOUND_HIP TRUE)
8585
find_package_and_print_version(hip REQUIRED CONFIG)
8686

87+
if(HIP_VERSION)
88+
# Check if HIP_VERSION contains a dash (e.g., "7.1.25421-32f9fa6ca5")
89+
# and strip everything after it to get clean numeric version
90+
string(FIND "${HIP_VERSION}" "-" DASH_POS)
91+
if(NOT DASH_POS EQUAL -1)
92+
string(SUBSTRING "${HIP_VERSION}" 0 ${DASH_POS} HIP_VERSION_CLEAN)
93+
set(HIP_VERSION "${HIP_VERSION_CLEAN}")
94+
endif()
95+
message("HIP version: ${HIP_VERSION}")
96+
endif()
97+
8798
# The rocm-core package was only introduced in ROCm 6.4, so we make it optional.
8899
find_package(rocm-core CONFIG)
89100

0 commit comments

Comments
 (0)