Skip to content

Commit 7a6774f

Browse files
committed
refactor(gpu-fitness): remove redundant is_available() call in fallback
Eliminate unnecessary nvidia-smi call in _run_gpu_test_fallback(). The function was calling is_available() before immediately trying nvidia-smi --list-gpus, resulting in redundant GPU detection. Direct attempt to list GPUs handles all failure cases without the pre-check. Also clean up ambiguous variable name 'l' → 'line' in list comprehension.
1 parent 766807b commit 7a6774f

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

runpod/serverless/modules/rp_gpu_fitness.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -178,24 +178,15 @@ def _run_gpu_test_fallback() -> None:
178178
Python fallback for GPU testing using nvidia-smi.
179179
180180
Less comprehensive than binary (doesn't test memory allocation) but validates
181-
basic GPU availability.
181+
basic GPU availability by checking GPU count.
182182
183183
Raises:
184184
RuntimeError: If GPUs not available or unhealthy
185185
"""
186186
log.debug("Running Python GPU fallback check")
187187

188188
try:
189-
# Use existing rp_cuda utility
190-
from ..utils.rp_cuda import is_available
191-
192-
if not is_available():
193-
raise RuntimeError(
194-
"GPU not available (nvidia-smi check failed). "
195-
"This is a fallback check - consider installing gpu_test binary."
196-
)
197-
198-
# Additional check: Count GPUs
189+
# List GPUs to verify availability and count
199190
result = subprocess.run(
200191
["nvidia-smi", "--list-gpus"],
201192
capture_output=True,
@@ -207,7 +198,7 @@ def _run_gpu_test_fallback() -> None:
207198
if result.returncode != 0:
208199
raise RuntimeError(f"nvidia-smi --list-gpus failed: {result.stderr}")
209200

210-
gpu_lines = [l for l in result.stdout.split("\n") if l.strip()]
201+
gpu_lines = [line for line in result.stdout.split("\n") if line.strip()]
211202
gpu_count = len(gpu_lines)
212203

213204
if gpu_count == 0:

0 commit comments

Comments
 (0)