2PyHelios Runtime GPU Detection Module
4This module provides runtime GPU detection capabilities for PyHelios testing and validation.
5Detection fails fast rather than falling back silently.
9from typing
import Dict, Any, Optional
11logger = logging.getLogger(__name__)
16 Check if GPU runtime (CUDA/OptiX) is available for PyHelios.
19 bool: True if GPU runtime is available, False otherwise
22 RuntimeError: If GPU detection system is unavailable (fail-fast)
25 from pyhelios.config.dependency_resolver
import PluginDependencyResolver
26 resolver = PluginDependencyResolver()
27 return resolver._check_cuda()
28 except ImportError
as e:
30 f
"GPU detection system unavailable: {e}. "
31 f
"This indicates a PyHelios installation or import issue."
33 except Exception
as e:
35 f
"GPU detection failed: {e}. "
36 f
"Check CUDA installation and GPU drivers."
42 Get detailed GPU runtime information for PyHelios.
45 Dict containing GPU runtime status and details
48 RuntimeError: If GPU detection system is unavailable (fail-fast)
51 from pyhelios.config.dependency_resolver
import PluginDependencyResolver
52 resolver = PluginDependencyResolver()
54 cuda_available = resolver._check_cuda()
57 'cuda_available': cuda_available,
58 'gpu_runtime_available': cuda_available,
61 if not cuda_available:
62 info[
'error_message'] =
'CUDA/GPU not available'
63 info[
'suggestions'] = [
64 'Install NVIDIA CUDA toolkit',
65 'Ensure NVIDIA GPU drivers are installed',
66 'Check that nvcc is in PATH'
71 except ImportError
as e:
73 f
"GPU detection system unavailable: {e}. "
74 f
"This indicates a PyHelios installation or import issue."
76 except Exception
as e:
78 f
"GPU detection failed: {e}. "
79 f
"Check CUDA installation and GPU drivers."
85 Validate that GPU requirements are met for GPU-dependent operations.
88 RuntimeError: If GPU requirements are not met (fail-fast)
92 error_msg = gpu_info.get(
'error_message',
'GPU not available')
93 suggestions = gpu_info.get(
'suggestions', [])
96 f
"GPU requirements not met: {error_msg}. "
97 f
"Required for GPU-dependent plugins (radiation, energybalance, etc.). "
98 f
"Solutions: {'; '.join(suggestions)}"
None validate_gpu_requirements()
Validate that GPU requirements are met for GPU-dependent operations.
bool is_gpu_runtime_available()
Check if GPU runtime (CUDA/OptiX) is available for PyHelios.
Dict[str, Any] get_gpu_runtime_info()
Get detailed GPU runtime information for PyHelios.