File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
crates/worker/src/checks/hardware Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,20 @@ pub fn detect_gpu() -> Vec<GpuSpecs> {
4545fn get_gpu_status ( ) -> Vec < GpuDevice > {
4646 let mut nvml_guard = NVML . lock ( ) . unwrap ( ) ;
4747
48+ // Read WORKER_VISIBLE_DEVICES environment variable
49+ let visible_devices: Option < Vec < u32 > > =
50+ std:: env:: var ( "WORKER_VISIBLE_DEVICES" ) . ok ( ) . and_then ( |s| {
51+ if s. trim ( ) . is_empty ( ) {
52+ None
53+ } else {
54+ Some (
55+ s. split ( ',' )
56+ . filter_map ( |idx| idx. trim ( ) . parse :: < u32 > ( ) . ok ( ) )
57+ . collect ( ) ,
58+ )
59+ }
60+ } ) ;
61+
4862 // Initialize NVML if not already initialized
4963 if nvml_guard. is_none ( ) {
5064 // Try to load the NVIDIA management library dynamically
@@ -94,6 +108,15 @@ fn get_gpu_status() -> Vec<GpuDevice> {
94108 std:: collections:: HashMap :: new ( ) ;
95109
96110 for i in 0 ..device_count {
111+ let device_index = i as u32 ;
112+
113+ // Skip this device if it's not in the visible devices list
114+ if let Some ( ref visible) = visible_devices {
115+ if !visible. contains ( & device_index) {
116+ continue ;
117+ }
118+ }
119+
97120 match nvml. device_by_index ( i as u32 ) {
98121 Ok ( device) => {
99122 let name = device. name ( ) . unwrap_or_else ( |_| "Unknown" . to_string ( ) ) ;
You can’t perform that action at this time.
0 commit comments