Suppress warning when using native arch for jit loading cuda extensions. (#156923)

Previeusly, if users want to let pytorch determine the cuda arch when jit loading cuda extensions, they should left environment variable `TORCH_CUDA_ARCH_LIST` empty, but which will raise an warning. This commit add an option to set `TORCH_CUDA_ARCH_LIST=native`, to tell pytorch users want to use native cuda arch intentionally.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156923
Approved by: https://github.com/ezyang
This commit is contained in:
Hao Zhang(张浩) 2025-07-09 02:51:20 +00:00 committed by PyTorch MergeBot
parent bc6e0661a6
commit ab8874bd26

View File

@ -2419,7 +2419,8 @@ def _get_cuda_arch_flags(cflags: Optional[list[str]] = None) -> list[str]:
# See cmake/Modules_CUDA_fix/upstream/FindCUDA/select_compute_arch.cmake
_arch_list = os.environ.get('TORCH_CUDA_ARCH_LIST', None)
# If not given, determine what's best for the GPU / CUDA version that can be found
# If not given or set as native, determine what's best for the GPU / CUDA version that can be found
if not _arch_list or _arch_list == "native":
if not _arch_list:
logger.warning(
"TORCH_CUDA_ARCH_LIST is not set, all archs for visible cards are included for compilation. \n"