mirror of
				https://github.com/pytorch/pytorch.git
				synced 2025-11-04 16:04:58 +08:00 
			
		
		
		
	[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: https://github.com/pytorch/pytorch/pull/159080 Approved by: https://github.com/jeffdaily
This commit is contained in:
		
				
					committed by
					
						
						PyTorch MergeBot
					
				
			
			
				
	
			
			
			
						parent
						
							e63c2b21c1
						
					
				
				
					commit
					ee89cc7a0a
				
			@ -6,7 +6,7 @@ set(PYTORCH_FOUND_HIP FALSE)
 | 
				
			|||||||
# In the latter case, if /opt/rocm does not exist emit status
 | 
					# In the latter case, if /opt/rocm does not exist emit status
 | 
				
			||||||
# message and return.
 | 
					# message and return.
 | 
				
			||||||
if(DEFINED ENV{ROCM_PATH})
 | 
					if(DEFINED ENV{ROCM_PATH})
 | 
				
			||||||
  set(ROCM_PATH $ENV{ROCM_PATH})
 | 
					  file(TO_CMAKE_PATH "$ENV{ROCM_PATH}" ROCM_PATH)
 | 
				
			||||||
  if(NOT EXISTS ${ROCM_PATH})
 | 
					  if(NOT EXISTS ${ROCM_PATH})
 | 
				
			||||||
    message(FATAL_ERROR
 | 
					    message(FATAL_ERROR
 | 
				
			||||||
      "ROCM_PATH environment variable is set to ${ROCM_PATH} but does not exist.\n"
 | 
					      "ROCM_PATH environment variable is set to ${ROCM_PATH} but does not exist.\n"
 | 
				
			||||||
@ -31,7 +31,7 @@ if(NOT DEFINED ENV{MAGMA_HOME})
 | 
				
			|||||||
  set(MAGMA_HOME ${ROCM_PATH}/magma)
 | 
					  set(MAGMA_HOME ${ROCM_PATH}/magma)
 | 
				
			||||||
  set(ENV{MAGMA_HOME} ${ROCM_PATH}/magma)
 | 
					  set(ENV{MAGMA_HOME} ${ROCM_PATH}/magma)
 | 
				
			||||||
else()
 | 
					else()
 | 
				
			||||||
  set(MAGMA_HOME $ENV{MAGMA_HOME})
 | 
					  file(TO_CMAKE_PATH "$ENV{MAGMA_HOME}" MAGMA_HOME)
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# MIOpen isn't a part of HIP-SDK for Windows and hence, may have a different
 | 
					# MIOpen isn't a part of HIP-SDK for Windows and hence, may have a different
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user