Skip to content

Conversation

ChrisRackauckas-Claude
Copy link
Contributor

Summary

  • Add CUDA.functional() check before creating CUDA arrays in init_cacheval functions
  • Return nothing if CUDA is loaded but not functional
  • Fixes issue where CudaOffloadLUFactorization and CudaOffloadQRFactorization would fail during cache initialization when CUDA is in environment but not usable

Details

The issue occurs when CUDA.jl is loaded in the environment but CUDA.functional() returns false (e.g., in CI environments without actual CUDA hardware). The init_cacheval functions for CUDA algorithms were trying to create CuVector and CuMatrix objects without checking if CUDA is functional, causing failures during default algorithm initialization.

Changes

  1. CudaOffloadLUFactorization: Added CUDA.functional() check before creating CuVector and CuMatrix in init_cacheval
  2. CudaOffloadQRFactorization: Added CUDA.functional() check before creating CUDA.CuArray in init_cacheval
  3. Both functions now return nothing when CUDA is not functional, matching the fallback behavior when the extension isn't loaded

Test plan

  • Verified package loads successfully
  • Confirmed init_cacheval returns nothing when CUDA not functional
  • Basic linear algebra operations work correctly
  • No errors during cache initialization for default algorithms

Closes #761

🤖 Generated with Claude Code

- Add CUDA.functional() check before creating CUDA arrays in init_cacheval
- Return nothing if CUDA is loaded but not functional
- Fixes issue where CudaOffloadLUFactorization and CudaOffloadQRFactorization
  would fail during cache initialization when CUDA is in environment but not usable
- Addresses issue SciML#761

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@ChrisRackauckas ChrisRackauckas merged commit 4c55f9e into SciML:main Sep 3, 2025
131 of 136 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't use cuda just because cuda is loaded
2 participants