Skip to content

Commit

Permalink
Allow for trailing 'a' in sm_arch (#126185)
Browse files Browse the repository at this point in the history
# Summary
I was getting
``` Shell
File "/home/drisspg/meta/pytorch/torch/cuda/__init__.py", line 312, in _lazy_init
    raise DeferredCudaCallError(msg) from e
torch.cuda.DeferredCudaCallError: CUDA call failed lazily at initialization with error: invalid literal for int() with base 10: '90a'
```

Pull Request resolved: #126185
Approved by: https://github.com/Skylion007
  • Loading branch information
drisspg authored and ZelboK committed May 19, 2024
1 parent 00b9974 commit 1dfe2d1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions torch/cuda/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ def _sleep(cycles):
torch._C._cuda_sleep(cycles)


def _extract_arch_version(arch_string: str):
"""Extracts the architecture string from a CUDA version"""
base = arch_string.split("_")[1]
if base.endswith("a"):
base = base[:-1]
return int(base)


def _check_capability():
incorrect_binary_warn = """
Found GPU%d %s which requires CUDA_VERSION >= %d to
Expand All @@ -177,7 +185,7 @@ def _check_capability():
name = get_device_name(d)
current_arch = major * 10 + minor
min_arch = min(
(int(arch.split("_")[1]) for arch in torch.cuda.get_arch_list()),
(_extract_arch_version(arch) for arch in torch.cuda.get_arch_list()),
default=35,
)
if current_arch < min_arch:
Expand All @@ -198,7 +206,7 @@ def _check_cubins():
arch_list = get_arch_list()
if len(arch_list) == 0:
return
supported_sm = [int(arch.split("_")[1]) for arch in arch_list if "sm_" in arch]
supported_sm = [_extract_arch_version(arch) for arch in arch_list if "sm_" in arch]
for idx in range(device_count()):
cap_major, cap_minor = get_device_capability(idx)
# NVIDIA GPU compute architectures are backward compatible within major version
Expand Down

0 comments on commit 1dfe2d1

Please sign in to comment.