From c500f1d13b1e2192d65aa8a3efa265bb9a8b7050 Mon Sep 17 00:00:00 2001 From: Peter Bell Date: Thu, 6 Jul 2023 01:59:36 +0100 Subject: [PATCH] [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 --- cmake/public/utils.cmake | 4 ++-- tools/setup_helpers/cmake.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cmake/public/utils.cmake b/cmake/public/utils.cmake index bab415de44d..4d48c0f0f3d 100644 --- a/cmake/public/utils.cmake +++ b/cmake/public/utils.cmake @@ -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 " diff --git a/tools/setup_helpers/cmake.py b/tools/setup_helpers/cmake.py index 1ed5b17f4cf..0bd6e5d4c2a 100644 --- a/tools/setup_helpers/cmake.py +++ b/tools/setup_helpers/cmake.py @@ -233,6 +233,7 @@ class CMake: "OPENSSL_ROOT_DIR", "STATIC_DISPATCH_BACKEND", "SELECTED_OP_LIST", + "TORCH_CUDA_ARCH_LIST", "TRACING_BASED", ) }