[CMake] Fix TORCH_CUDA_ARCH_LIST warning (#104680)

The warning complains that `TORCH_CUDA_ARCH_LIST` is set on the environment
instead of being defined as a build variable, which is fixed by the change to
`tools/setup_helpers/cmake.py`.

However, I still see the warning even with this fix because
```cmake
if((NOT EXISTS ${TORCH_CUDA_ARCH_LIST}) ...
```
is actually checking whether a file exists called "7.5" (or whatever arch is
being requested). Instead we want to check if the variable is defined.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/104680
Approved by: https://github.com/albanD
This commit is contained in:
Peter Bell 2023-07-06 01:59:36 +01:00 committed by PyTorch MergeBot
parent 6970ffbbc7
commit c500f1d13b
2 changed files with 3 additions and 2 deletions

View file

@ -381,7 +381,7 @@ endmacro()
#
macro(torch_cuda_get_nvcc_gencode_flag store_var)
# setting nvcc arch flags
if((NOT EXISTS ${TORCH_CUDA_ARCH_LIST}) AND (DEFINED ENV{TORCH_CUDA_ARCH_LIST}))
if((NOT DEFINED TORCH_CUDA_ARCH_LIST) AND (DEFINED ENV{TORCH_CUDA_ARCH_LIST}))
message(WARNING
"In the future we will require one to explicitly pass "
"TORCH_CUDA_ARCH_LIST to cmake instead of implicitly setting it as an "
@ -389,7 +389,7 @@ macro(torch_cuda_get_nvcc_gencode_flag store_var)
"pytorch.")
set(TORCH_CUDA_ARCH_LIST $ENV{TORCH_CUDA_ARCH_LIST})
endif()
if(EXISTS ${CUDA_ARCH_NAME})
if(DEFINED CUDA_ARCH_NAME)
message(WARNING
"CUDA_ARCH_NAME is no longer used. Use TORCH_CUDA_ARCH_LIST instead. "
"Right now, CUDA_ARCH_NAME is ${CUDA_ARCH_NAME} and "

View file

@ -233,6 +233,7 @@ class CMake:
"OPENSSL_ROOT_DIR",
"STATIC_DISPATCH_BACKEND",
"SELECTED_OP_LIST",
"TORCH_CUDA_ARCH_LIST",
"TRACING_BASED",
)
}