Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check cuda device capability for triton kernel initialization. #93

Merged
merged 4 commits into from
Sep 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions hippynn/custom_kernels/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,18 @@

try:
import triton
import torch
device_capability = torch.cuda.get_device_capability()
if device_capability[0] > 6:
CUSTOM_KERNELS_AVAILABLE.append("triton")
else:
warnings.warn(
f"Triton found but not supported by GPU's compute capability: {device_capability}"
)
except ImportError:
pass

CUSTOM_KERNELS_AVAILABLE.append("triton")
except ImportError:
pass

Expand Down Expand Up @@ -76,7 +86,7 @@ def _check_cupy():
if not cupy.cuda.is_available():
if torch.cuda.is_available():
warnings.warn("cupy.cuda.is_available() returned False: Custom kernels will fail on GPU tensors.")


def set_custom_kernels(active: Union[bool, str] = True):
"""
Expand Down Expand Up @@ -113,7 +123,6 @@ def set_custom_kernels(active: Union[bool, str] = True):
return

# Select custom kernel implementation

if not CUSTOM_KERNELS_AVAILABLE:
raise RuntimeError("Numba was not found. Custom kernels are not available.")

Expand Down
Loading