Skip to content

Commit 6c649a9

Browse files
fix(gpu_amd): only extend amdsmi import except types
Keep original warning message and comment; catch OSError and KeyError when libamd_smi fails to load (e.g. macOS with amdsmi wheel but no ROCm). Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 6034901 commit 6c649a9

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

codecarbon/core/gpu_amd.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ def is_rocm_system():
2828
"Please install amdsmi to get GPU metrics."
2929
)
3030
AMDSMI_AVAILABLE = False
31-
except (AttributeError, OSError, KeyError) as error:
31+
except (AttributeError, OSError, KeyError) as e:
3232
amdsmi = None
33+
# In some environments, amdsmi may be present but not properly configured, leading to AttributeError when importing
3334
logger.warning(
34-
"amdsmi is installed but could not load libamd_smi (ROCm drivers missing "
35-
"or incompatible). AMD GPU metrics will be unavailable. Error: %s",
36-
error,
35+
"AMD GPU detected but amdsmi is not properly configured. "
36+
"Please ensure amdsmi is correctly installed to get GPU metrics."
37+
"Tips : check consistency between Python amdsmi package and ROCm versions, and ensure AMD drivers are up to date."
38+
f" Error: {e}"
3739
)
3840
AMDSMI_AVAILABLE = False
3941

0 commit comments

Comments
 (0)