Skip to content

fix: Improve CUDA version detection and error handling #1599

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 3 commits into from
Apr 17, 2025

Conversation

ved1beta
Copy link
Contributor

fix: Improve CUDA/HIP version detection and error handling

This commit fixes issue #1513 by improving the version detection logic
in cuda_specs.py to handle both CUDA and ROCm/HIP systems more robustly.

Key changes:

  • Add proper error handling for None values in version detection
  • Make version string and tuple functions return Optional types
  • Add robust version string parsing with try-except blocks
  • Add validation checks for compute capabilities
  • Improve error handling in get_cuda_specs function
  • Add proper type hints and documentation

The changes ensure that:

  1. NoneType errors are properly handled when version info is missing
  2. ROCm/HIP systems are properly supported
  3. Invalid version strings don't cause crashes
  4. All error cases return None instead of raising exceptions

Test results show successful version detection for both CUDA and ROCm/HIP
systems, resolving the original issue where torch.version.cuda.split()
would fail on ROCm systems.

Copy link

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@matthewdouglas
Copy link
Member

LGTM, thanks! We can merge after fixing the failing linter check.

@matthewdouglas matthewdouglas linked an issue Apr 17, 2025 that may be closed by this pull request
@matthewdouglas matthewdouglas merged commit feaedbb into bitsandbytes-foundation:main Apr 17, 2025
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

torch.version.cuda.split error
2 participants