CMake: Loosen CUDA consistency check (#113174)

Closes #108931, closes #108932, see also conda-forge/pytorch-cpu-feedstock#203

Currently we compare `CUDA_INCLUDE_DIRS` and expect exact equality
with `CUDAToolkit_INCLUDE_DIR` however this fails in the presense of
symbolic links or for split installs where there are multiple include paths.
Given that, it makes sense to loosen the requirement to just version
equality under the assumption that two installs of the same version
should still be compatible.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/113174
Approved by: https://github.com/malfet
This commit is contained in:
Peter Bell
2023-11-07 17:23:46 +00:00
committed by PyTorch MergeBot
parent b7acd374c9
commit 93cea394de

View File

@ -60,11 +60,10 @@ find_package(CUDAToolkit REQUIRED)
cmake_policy(POP)
if(NOT CMAKE_CUDA_COMPILER_VERSION STREQUAL CUDAToolkit_VERSION OR
NOT CUDA_INCLUDE_DIRS STREQUAL CUDAToolkit_INCLUDE_DIR)
message(FATAL_ERROR "Found two conflicting CUDA installs:\n"
if(NOT CMAKE_CUDA_COMPILER_VERSION VERSION_EQUAL CUDAToolkit_VERSION)
message(FATAL_ERROR "Found two conflicting CUDA versions:\n"
"V${CMAKE_CUDA_COMPILER_VERSION} in '${CUDA_INCLUDE_DIRS}' and\n"
"V${CUDAToolkit_VERSION} in '${CUDAToolkit_INCLUDE_DIR}'")
"V${CUDAToolkit_VERSION} in '${CUDAToolkit_INCLUDE_DIRS}'")
endif()
if(NOT TARGET CUDA::nvToolsExt)