Skip to content

Uses torch.version.cuda to compile CUDA extensions #2163

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

Merged
merged 2 commits into from
May 2, 2025
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
12 changes: 5 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,23 +253,21 @@ def get_extensions():
if debug_mode:
print("Compiling in debug mode")

if not torch.cuda.is_available():
if not torch.version.cuda:
print(
"PyTorch GPU support is not available. Skipping compilation of CUDA extensions"
)
if CUDA_HOME is None and torch.cuda.is_available() and torch.version.cuda:
if CUDA_HOME is None and torch.version.cuda:
print("CUDA toolkit is not available. Skipping compilation of CUDA extensions")
print(
"If you'd like to compile CUDA extensions locally please install the cudatoolkit from https://anaconda.org/nvidia/cuda-toolkit"
)
if ROCM_HOME is None and torch.cuda.is_available() and torch.version.hip:
if ROCM_HOME is None and torch.version.hip:
print("ROCm is not available. Skipping compilation of ROCm extensions")
print("If you'd like to compile ROCm extensions locally please install ROCm")

use_cuda = (
torch.cuda.is_available() and torch.version.cuda and CUDA_HOME is not None
)
use_hip = torch.cuda.is_available() and torch.version.hip and ROCM_HOME is not None
use_cuda = torch.version.cuda and CUDA_HOME is not None
use_hip = torch.version.hip and ROCM_HOME is not None
extension = CUDAExtension if (use_cuda or use_hip) else CppExtension

nvcc_args = [
Expand Down
Loading