Skip to content

Commit ee89cc7

Browse files
ScottToddpytorchmergebot
authored andcommitted
[ROCm][Windows] Fix LoadHIP handling of environment variable paths on Windows. (#159080)
See https://cmake.org/cmake/help/latest/command/file.html#path-conversion. Paths stored in environment variables may use `/` or `\` (e.g. on Windows), while cmake-style paths always use `/`. This fixes configure errors like: ``` CMake Error at D:/b/pytorch_main/build/CMakeFiles/CMakeScratch/TryCompile-srhq07/CMakeLists.txt:2 (set): Syntax error in cmake code at D:/b/pytorch_main/build/CMakeFiles/CMakeScratch/TryCompile-srhq07/CMakeLists.txt:2 when parsing string D:\projects\TheRock\external-builds\pytorch\.venv\Lib\site-packages\_rocm_sdk_devel/cmake/;D:/b/pytorch_main/cmake/Modules Invalid character escape '\p'. CMake Error at D:/projects/TheRock/external-builds/pytorch/.venv/Lib/site-packages/cmake/data/share/cmake-3.31/Modules/Internal/CheckSourceCompiles.cmake:108 (try_compile): Failed to configure test project build system. ``` (note the mixed usage of `\` and `/` in that string) Pull Request resolved: #159080 Approved by: https://github.com/jeffdaily
1 parent e63c2b2 commit ee89cc7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cmake/public/LoadHIP.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set(PYTORCH_FOUND_HIP FALSE)
66
# In the latter case, if /opt/rocm does not exist emit status
77
# message and return.
88
if(DEFINED ENV{ROCM_PATH})
9-
set(ROCM_PATH $ENV{ROCM_PATH})
9+
file(TO_CMAKE_PATH "$ENV{ROCM_PATH}" ROCM_PATH)
1010
if(NOT EXISTS ${ROCM_PATH})
1111
message(FATAL_ERROR
1212
"ROCM_PATH environment variable is set to ${ROCM_PATH} but does not exist.\n"
@@ -31,7 +31,7 @@ if(NOT DEFINED ENV{MAGMA_HOME})
3131
set(MAGMA_HOME ${ROCM_PATH}/magma)
3232
set(ENV{MAGMA_HOME} ${ROCM_PATH}/magma)
3333
else()
34-
set(MAGMA_HOME $ENV{MAGMA_HOME})
34+
file(TO_CMAKE_PATH "$ENV{MAGMA_HOME}" MAGMA_HOME)
3535
endif()
3636

3737
# MIOpen isn't a part of HIP-SDK for Windows and hence, may have a different

0 commit comments

Comments
 (0)