Skip to content

Commit 0b62a9f

Browse files
committed
[GPU] AMD Plugin: Operation not permitted #3125
1 parent cb22a0c commit 0b62a9f

File tree

1 file changed

+20
-4
lines changed
  • glances/plugins/gpu/cards

1 file changed

+20
-4
lines changed

glances/plugins/gpu/cards/amd.py

+20-4
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,17 @@ def get_mem(device_folder: str) -> Optional[int]:
110110
mem_info_vram_used = os.path.join(device_folder, GPU_MEM_USED)
111111
if os.path.isfile(mem_info_vram_total) and os.path.isfile(mem_info_vram_used):
112112
with open(mem_info_vram_total) as f:
113-
mem_info_vram_total = int(f.read())
113+
try:
114+
mem_info_vram_total = int(f.read())
115+
except PermissionError:
116+
# Catch exception (see issue #3125)
117+
return None
114118
with open(mem_info_vram_used) as f:
115-
mem_info_vram_used = int(f.read())
119+
try:
120+
mem_info_vram_used = int(f.read())
121+
except PermissionError:
122+
# Catch exception (see issue #3125)
123+
return None
116124
if mem_info_vram_total > 0:
117125
return round(mem_info_vram_used / mem_info_vram_total * 100)
118126
return None
@@ -123,7 +131,11 @@ def get_proc(device_folder: str) -> Optional[int]:
123131
gpu_busy_percent = os.path.join(device_folder, GPU_PROC_PERCENT)
124132
if os.path.isfile(gpu_busy_percent):
125133
with open(gpu_busy_percent) as f:
126-
return int(f.read())
134+
try:
135+
return int(f.read())
136+
except PermissionError:
137+
# Catch exception (see issue #3125)
138+
return None
127139
return None
128140

129141

@@ -137,7 +149,11 @@ def get_temperature(device_folder: str) -> Optional[int]:
137149
for f in files:
138150
if re.match(GPU_TEMPERATURE_REGEXP, f):
139151
with open(os.path.join(root, d, f)) as f:
140-
temp_input.append(int(f.read()))
152+
try:
153+
temp_input.append(int(f.read()))
154+
except PermissionError:
155+
# Catch exception (see issue #3125)
156+
return None
141157
if temp_input:
142158
return round(sum(temp_input) / len(temp_input) / 1000)
143159
return None

0 commit comments

Comments
 (0)