gpustack-runtime 0.1.39.post2__py3-none-any.whl → 0.1.40__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. gpustack_runtime/__main__.py +7 -3
  2. gpustack_runtime/_version.py +2 -2
  3. gpustack_runtime/_version_appendix.py +1 -1
  4. gpustack_runtime/cmds/__init__.py +2 -0
  5. gpustack_runtime/cmds/deployer.py +84 -2
  6. gpustack_runtime/cmds/images.py +2 -0
  7. gpustack_runtime/deployer/__init__.py +2 -0
  8. gpustack_runtime/deployer/__types__.py +52 -28
  9. gpustack_runtime/deployer/__utils__.py +99 -112
  10. gpustack_runtime/deployer/cdi/__init__.py +81 -0
  11. gpustack_runtime/deployer/cdi/__types__.py +667 -0
  12. gpustack_runtime/deployer/cdi/thead.py +103 -0
  13. gpustack_runtime/deployer/docker.py +42 -24
  14. gpustack_runtime/deployer/kuberentes.py +8 -4
  15. gpustack_runtime/deployer/podman.py +41 -23
  16. gpustack_runtime/detector/__init__.py +62 -3
  17. gpustack_runtime/detector/__types__.py +11 -0
  18. gpustack_runtime/detector/__utils__.py +23 -0
  19. gpustack_runtime/detector/amd.py +17 -9
  20. gpustack_runtime/detector/hygon.py +6 -1
  21. gpustack_runtime/detector/iluvatar.py +20 -5
  22. gpustack_runtime/detector/mthreads.py +8 -12
  23. gpustack_runtime/detector/nvidia.py +365 -168
  24. gpustack_runtime/detector/pyacl/__init__.py +9 -1
  25. gpustack_runtime/detector/pyamdgpu/__init__.py +8 -0
  26. gpustack_runtime/detector/pycuda/__init__.py +9 -1
  27. gpustack_runtime/detector/pydcmi/__init__.py +9 -2
  28. gpustack_runtime/detector/pyhgml/__init__.py +5879 -0
  29. gpustack_runtime/detector/pyhgml/libhgml.so +0 -0
  30. gpustack_runtime/detector/pyhgml/libuki.so +0 -0
  31. gpustack_runtime/detector/pyhsa/__init__.py +9 -0
  32. gpustack_runtime/detector/pyixml/__init__.py +89 -164
  33. gpustack_runtime/detector/pyrocmcore/__init__.py +42 -24
  34. gpustack_runtime/detector/pyrocmsmi/__init__.py +141 -138
  35. gpustack_runtime/detector/thead.py +733 -0
  36. gpustack_runtime/envs.py +128 -55
  37. {gpustack_runtime-0.1.39.post2.dist-info → gpustack_runtime-0.1.40.dist-info}/METADATA +4 -2
  38. gpustack_runtime-0.1.40.dist-info/RECORD +55 -0
  39. gpustack_runtime/detector/pymtml/__init__.py +0 -770
  40. gpustack_runtime-0.1.39.post2.dist-info/RECORD +0 -49
  41. {gpustack_runtime-0.1.39.post2.dist-info → gpustack_runtime-0.1.40.dist-info}/WHEEL +0 -0
  42. {gpustack_runtime-0.1.39.post2.dist-info → gpustack_runtime-0.1.40.dist-info}/entry_points.txt +0 -0
  43. {gpustack_runtime-0.1.39.post2.dist-info → gpustack_runtime-0.1.40.dist-info}/licenses/LICENSE +0 -0
@@ -11,6 +11,50 @@ import threading
11
11
  from ctypes import *
12
12
  from functools import wraps
13
13
  from pathlib import Path
14
+ from typing import ClassVar
15
+
16
+ # Example ROCM_SMI_LIB_PATH
17
+ # - /opt/hyhal/lib
18
+ # - /opt/rocm/rocm_smi/lib
19
+ # Example ROCM_PATH/ROCM_HOME
20
+ # - /opt/dtk-24.04.3
21
+ # - /opt/dtk
22
+ # - /opt/rocm
23
+ rocmsmi_lib_path = os.getenv("ROCM_SMI_LIB_PATH")
24
+ if not rocmsmi_lib_path:
25
+ rocm_path = Path(os.getenv("ROCM_HOME", os.getenv("ROCM_PATH") or "/opt/rocm"))
26
+ rocmsmi_lib_path = str(rocm_path / "lib")
27
+ if not Path(rocmsmi_lib_path).exists():
28
+ rocmsmi_lib_path = str(rocm_path / "rocm_smi" / "lib")
29
+ else:
30
+ rocm_path = Path(
31
+ os.getenv(
32
+ "ROCM_HOME",
33
+ os.getenv("ROCM_PATH") or str(Path(rocmsmi_lib_path).parent.parent),
34
+ )
35
+ )
36
+
37
+ rocmsmi_lib_loc = Path(rocmsmi_lib_path) / "librocm_smi64.so"
38
+ if rocmsmi_lib_loc.exists():
39
+ rocmsmi_bindings_paths = [
40
+ (rocm_path / "rocm_smi" / "bindings"),
41
+ (rocm_path / "libexec" / "rocm_smi"),
42
+ ]
43
+ rocmsmi_bindings_path = None
44
+ for p in rocmsmi_bindings_paths:
45
+ if p.exists():
46
+ rocmsmi_bindings_path = p
47
+ break
48
+
49
+ # Refer to https://github.com/ROCm/rocm_smi_lib/blob/amd-staging_deprecated/python_smi_tools/rsmiBindings.py.
50
+ # Add bindings path to sys.path for importing rsmiBindings
51
+ if rocmsmi_bindings_path and rocmsmi_bindings_path.exists():
52
+ if str(rocmsmi_bindings_path) not in sys.path:
53
+ sys.path.append(str(rocmsmi_bindings_path))
54
+ try:
55
+ from rsmiBindings import *
56
+ except ImportError:
57
+ pass
14
58
 
15
59
  ## Enums ##
16
60
  ROCMSMI_IOLINK_TYPE_UNDEFINED = 0
@@ -20,66 +64,42 @@ ROCMSMI_IOLINK_TYPE_NUMIOLINKTYPES = 3
20
64
 
21
65
  ## Error Codes ##
22
66
  ROCMSMI_ERROR_UNINITIALIZED = -99997
67
+ ROCMSMI_ERROR_FUNCTION_NOT_FOUND = -99998
23
68
 
24
69
  ## Lib loading ##
25
70
  rocmsmiLib = None
26
71
  libLoadLock = threading.Lock()
27
72
 
28
- if rocmsmiLib is None:
29
- # Example ROCM_SMI_LIB_PATH
30
- # - /opt/hyhal/lib
31
- # - /opt/rocm/rocm_smi/lib
32
- # Example ROCM_PATH/ROCM_HOME
33
- # - /opt/dtk-24.04.3
34
- # - /opt/dtk
35
- # - /opt/rocm
36
- rocmsmi_lib_path = os.getenv("ROCM_SMI_LIB_PATH")
37
- if not rocmsmi_lib_path:
38
- rocm_path = Path(os.getenv("ROCM_HOME", os.getenv("ROCM_PATH") or "/opt/rocm"))
39
- rocmsmi_lib_path = str(rocm_path / "lib")
40
- if not Path(rocmsmi_lib_path).exists():
41
- rocmsmi_lib_path = str(rocm_path / "rocm_smi" / "lib")
42
- else:
43
- rocm_path = Path(
44
- os.getenv(
45
- "ROCM_HOME",
46
- os.getenv("ROCM_PATH") or str(Path(rocmsmi_lib_path).parent.parent),
47
- )
48
- )
49
-
50
- rocmsmi_lib_loc = Path(rocmsmi_lib_path) / "librocm_smi64.so"
51
- if rocmsmi_lib_loc.exists():
52
- rocmsmi_bindings_paths = [
53
- (rocm_path / "rocm_smi" / "bindings"),
54
- (rocm_path / "libexec" / "rocm_smi"),
55
- ]
56
- rocmsmi_bindings_path = None
57
- for p in rocmsmi_bindings_paths:
58
- if p.exists():
59
- rocmsmi_bindings_path = p
60
- break
61
73
 
62
- if rocmsmi_bindings_path and rocmsmi_bindings_path.exists():
63
- if str(rocmsmi_bindings_path) not in sys.path:
64
- sys.path.append(str(rocmsmi_bindings_path))
65
-
66
- libLoadLock.acquire()
67
-
68
- try:
69
- # Refer to https://github.com/ROCm/rocm_smi_lib/blob/amd-staging_deprecated/python_smi_tools/rsmiBindings.py.
70
- from rsmiBindings import *
71
-
72
- if not rocmsmiLib:
73
- rocmsmiLib = CDLL(rocmsmi_lib_loc)
74
- except OSError:
75
- pass
76
- finally:
77
- libLoadLock.release()
74
+ def _LoadRocmSmiLibrary():
75
+ """
76
+ Load the library if it isn't loaded already.
77
+ """
78
+ global rocmsmiLib
79
+
80
+ if rocmsmiLib is None:
81
+ # lock to ensure only one caller loads the library
82
+ libLoadLock.acquire()
83
+ try:
84
+ # ensure the library still isn't loaded
85
+ if (
86
+ rocmsmiLib is None
87
+ and not sys.platform.startswith("win")
88
+ and rocmsmi_lib_loc.is_file()
89
+ ):
90
+ try:
91
+ rocmsmiLib = CDLL(str(rocmsmi_lib_loc))
92
+ except OSError:
93
+ pass
94
+ finally:
95
+ # lock is always released
96
+ libLoadLock.release()
78
97
 
79
98
 
80
99
  class ROCMSMIError(Exception):
81
100
  _extend_errcode_to_string: ClassVar[dict[int, str]] = {
82
101
  ROCMSMI_ERROR_UNINITIALIZED: "Library Not Initialized",
102
+ ROCMSMI_ERROR_FUNCTION_NOT_FOUND: "Function Not Found in Library",
83
103
  }
84
104
 
85
105
  def __init__(self, value):
@@ -99,6 +119,31 @@ def _rocmsmiCheckReturn(ret):
99
119
  return ret
100
120
 
101
121
 
122
+ ## Function access ##
123
+ _rocmsmiGetFunctionPointer_cache = {} # function pointers are cached to prevent unnecessary libLoadLock locking
124
+
125
+
126
+ def _rocmsmiGetFunctionPointer(name):
127
+ global rocmsmiLib
128
+
129
+ if name in _rocmsmiGetFunctionPointer_cache:
130
+ return _rocmsmiGetFunctionPointer_cache[name]
131
+
132
+ libLoadLock.acquire()
133
+ try:
134
+ # ensure library was loaded
135
+ if rocmsmiLib is None:
136
+ raise ROCMSMIError(ROCMSMI_ERROR_UNINITIALIZED)
137
+ try:
138
+ _rocmsmiGetFunctionPointer_cache[name] = getattr(rocmsmiLib, name)
139
+ return _rocmsmiGetFunctionPointer_cache[name]
140
+ except AttributeError:
141
+ raise ROCMSMIError(ROCMSMI_ERROR_FUNCTION_NOT_FOUND)
142
+ finally:
143
+ # lock is always freed
144
+ libLoadLock.release()
145
+
146
+
102
147
  ## string/bytes conversion for ease of use
103
148
  def convertStrBytes(func):
104
149
  @wraps(func)
@@ -120,132 +165,108 @@ def convertStrBytes(func):
120
165
 
121
166
  ## C function wrappers ##
122
167
  def rsmi_init(flags=0):
123
- if not rocmsmiLib:
124
- raise ROCMSMIError(ROCMSMI_ERROR_UNINITIALIZED)
168
+ _LoadRocmSmiLibrary()
125
169
 
126
- ret = rocmsmiLib.rsmi_init(flags)
170
+ fn = _rocmsmiGetFunctionPointer("rsmi_init")
171
+ ret = fn(flags)
127
172
  _rocmsmiCheckReturn(ret)
128
173
 
129
174
 
130
175
  @convertStrBytes
131
176
  def rsmi_driver_version_get():
132
- if not rocmsmiLib:
133
- raise ROCMSMIError(ROCMSMI_ERROR_UNINITIALIZED)
134
-
135
177
  component = rsmi_sw_component_t.RSMI_SW_COMP_DRIVER
136
178
  c_version = create_string_buffer(256)
137
- ret = rocmsmiLib.rsmi_version_str_get(component, c_version, 256)
179
+ fn = _rocmsmiGetFunctionPointer("rsmi_version_str_get")
180
+ ret = fn(component, c_version, 256)
138
181
  _rocmsmiCheckReturn(ret)
139
182
  return c_version.value
140
183
 
141
184
 
142
185
  def rsmi_num_monitor_devices():
143
- if not rocmsmiLib:
144
- raise ROCMSMIError(ROCMSMI_ERROR_UNINITIALIZED)
145
-
146
186
  c_num_devices = c_uint32()
147
- ret = rocmsmiLib.rsmi_num_monitor_devices(byref(c_num_devices))
187
+ fn = _rocmsmiGetFunctionPointer("rsmi_num_monitor_devices")
188
+ ret = fn(byref(c_num_devices))
148
189
  _rocmsmiCheckReturn(ret)
149
190
  return c_num_devices.value
150
191
 
151
192
 
152
193
  @convertStrBytes
153
194
  def rsmi_dev_name_get(device=0):
154
- if not rocmsmiLib:
155
- raise ROCMSMIError(ROCMSMI_ERROR_UNINITIALIZED)
156
-
157
195
  c_name = create_string_buffer(256)
158
- ret = rocmsmiLib.rsmi_dev_name_get(device, c_name, 256)
196
+ fn = _rocmsmiGetFunctionPointer("rsmi_dev_name_get")
197
+ ret = fn(device, c_name, 256)
159
198
  _rocmsmiCheckReturn(ret)
160
199
  return c_name.value
161
200
 
162
201
 
163
202
  @convertStrBytes
164
203
  def rsmi_dev_serial_number_get(device=0):
165
- if not rocmsmiLib:
166
- raise ROCMSMIError(ROCMSMI_ERROR_UNINITIALIZED)
167
-
168
204
  c_serial = create_string_buffer(256)
169
- ret = rocmsmiLib.rsmi_dev_serial_number_get(device, c_serial, 256)
205
+ fn = _rocmsmiGetFunctionPointer("rsmi_dev_serial_number_get")
206
+ ret = fn(device, c_serial, 256)
170
207
  _rocmsmiCheckReturn(ret)
171
208
  return c_serial.value
172
209
 
173
210
 
174
211
  def rsmi_dev_unique_id_get(device=0):
175
- if not rocmsmiLib:
176
- raise ROCMSMIError(ROCMSMI_ERROR_UNINITIALIZED)
177
-
178
212
  c_uid = c_uint64()
179
- ret = rocmsmiLib.rsmi_dev_unique_id_get(device, byref(c_uid))
213
+ fn = _rocmsmiGetFunctionPointer("rsmi_dev_unique_id_get")
214
+ ret = fn(device, byref(c_uid))
180
215
  _rocmsmiCheckReturn(ret)
181
216
  return hex(c_uid.value)
182
217
 
183
218
 
184
219
  def rsmi_dev_busy_percent_get(device=0):
185
- if not rocmsmiLib:
186
- raise ROCMSMIError(ROCMSMI_ERROR_UNINITIALIZED)
187
-
188
220
  c_percent = c_uint32()
189
- ret = rocmsmiLib.rsmi_dev_busy_percent_get(device, byref(c_percent))
221
+ fn = _rocmsmiGetFunctionPointer("rsmi_dev_busy_percent_get")
222
+ ret = fn(device, byref(c_percent))
190
223
  _rocmsmiCheckReturn(ret)
191
224
  return c_percent.value
192
225
 
193
226
 
194
227
  def rsmi_dev_memory_usage_get(device=0, memory_type=None):
195
- if not rocmsmiLib:
196
- raise ROCMSMIError(ROCMSMI_ERROR_UNINITIALIZED)
197
-
198
228
  if memory_type is None:
199
229
  memory_type = rsmi_memory_type_t.RSMI_MEM_TYPE_VRAM
200
230
  c_used = c_uint64()
201
- ret = rocmsmiLib.rsmi_dev_memory_usage_get(device, memory_type, byref(c_used))
231
+ fn = _rocmsmiGetFunctionPointer("rsmi_dev_memory_usage_get")
232
+ ret = fn(device, memory_type, byref(c_used))
202
233
  _rocmsmiCheckReturn(ret)
203
234
  return c_used.value
204
235
 
205
236
 
206
237
  def rsmi_dev_memory_total_get(device=0, memory_type=None):
207
- if not rocmsmiLib:
208
- raise ROCMSMIError(ROCMSMI_ERROR_UNINITIALIZED)
209
-
210
238
  if memory_type is None:
211
239
  memory_type = rsmi_memory_type_t.RSMI_MEM_TYPE_VRAM
212
240
  c_total = c_uint64()
213
- ret = rocmsmiLib.rsmi_dev_memory_total_get(device, memory_type, byref(c_total))
241
+ fn = _rocmsmiGetFunctionPointer("rsmi_dev_memory_total_get")
242
+ ret = fn(device, memory_type, byref(c_total))
214
243
  _rocmsmiCheckReturn(ret)
215
244
  return c_total.value
216
245
 
217
246
 
218
247
  def rsmi_dev_target_graphics_version_get(device=0):
219
- if not rocmsmiLib:
220
- raise ROCMSMIError(ROCMSMI_ERROR_UNINITIALIZED)
221
-
222
248
  try:
223
249
  c_version = c_uint64()
224
- ret = rocmsmiLib.rsmi_dev_target_graphics_version_get(device, byref(c_version))
250
+ fn = _rocmsmiGetFunctionPointer("rsmi_dev_target_graphics_version_get")
251
+ ret = fn(device, byref(c_version))
225
252
  _rocmsmiCheckReturn(ret)
226
- version = str(c_version.value)
227
- if len(version) == 4:
228
- dev_name = rsmi_dev_name_get(device)
229
- if "Instinct MI2" in dev_name:
230
- hex_part = str(hex(int(version[2:]))).replace("0x", "")
231
- version = version[:2] + hex_part
232
- else:
233
- version = str(c_version.value // 10 + c_version.value % 10)
234
- return "gfx" + version
253
+ if c_version.value < 2000:
254
+ return "gfx" + str(c_version.value)
255
+ return "gfx" + hex(c_version.value)[2:]
235
256
  except AttributeError:
236
257
  return None
237
258
 
238
259
 
239
260
  def rsmi_dev_temp_metric_get(device=0, sensor=None, metric=None):
240
- if not rocmsmiLib:
241
- raise ROCMSMIError(ROCMSMI_ERROR_UNINITIALIZED)
242
-
243
261
  if metric is None:
244
262
  metric = rsmi_temperature_metric_t.RSMI_TEMP_CURRENT
245
263
 
264
+ fn = _rocmsmiGetFunctionPointer("rsmi_dev_temp_metric_get")
265
+
246
266
  if sensor is not None:
247
267
  c_temp = c_int64(0)
248
- ret = rocmsmiLib.rsmi_dev_temp_metric_get(
268
+
269
+ ret = fn(
249
270
  c_uint32(device),
250
271
  sensor,
251
272
  metric,
@@ -258,7 +279,7 @@ def rsmi_dev_temp_metric_get(device=0, sensor=None, metric=None):
258
279
  # try all sensors and return the first valid temperature.
259
280
  for sensor_i in range(7):
260
281
  c_temp = c_int64(0)
261
- ret = rocmsmiLib.rsmi_dev_temp_metric_get(
282
+ ret = fn(
262
283
  c_uint32(device),
263
284
  sensor_i,
264
285
  metric,
@@ -271,34 +292,28 @@ def rsmi_dev_temp_metric_get(device=0, sensor=None, metric=None):
271
292
 
272
293
 
273
294
  def rsmi_dev_power_cap_get(device=0):
274
- if not rocmsmiLib:
275
- raise ROCMSMIError(ROCMSMI_ERROR_UNINITIALIZED)
276
-
277
295
  c_power_cap = c_uint64(0)
278
- ret = rocmsmiLib.rsmi_dev_power_cap_get(device, 0, byref(c_power_cap))
296
+ fn = _rocmsmiGetFunctionPointer("rsmi_dev_power_cap_get")
297
+ ret = fn(device, 0, byref(c_power_cap))
279
298
  _rocmsmiCheckReturn(ret)
280
299
  return c_power_cap.value // 1000000
281
300
 
282
301
 
283
302
  def rsmi_dev_power_ave_get(device=0):
284
- if not rocmsmiLib:
285
- raise ROCMSMIError(ROCMSMI_ERROR_UNINITIALIZED)
286
-
287
303
  c_device_chip = c_uint32(0)
288
304
  c_power = c_uint64(0)
289
- ret = rocmsmiLib.rsmi_dev_power_ave_get(device, c_device_chip, byref(c_power))
305
+ fn = _rocmsmiGetFunctionPointer("rsmi_dev_power_ave_get")
306
+ ret = fn(device, c_device_chip, byref(c_power))
290
307
  _rocmsmiCheckReturn(ret)
291
308
  return c_power.value // 1000000
292
309
 
293
310
 
294
311
  def rsmi_dev_power_get(device=0):
295
- if not rocmsmiLib:
296
- raise ROCMSMIError(ROCMSMI_ERROR_UNINITIALIZED)
297
-
298
312
  try:
299
313
  c_power = c_uint64(0)
300
314
  c_power_type = rsmi_power_type_t()
301
- ret = rocmsmiLib.rsmi_dev_power_get(device, byref(c_power), byref(c_power_type))
315
+ fn = _rocmsmiGetFunctionPointer("rsmi_dev_power_get")
316
+ ret = fn(device, byref(c_power), byref(c_power_type))
302
317
  _rocmsmiCheckReturn(ret)
303
318
  return c_power.value // 1000000
304
319
  except NameError:
@@ -307,21 +322,17 @@ def rsmi_dev_power_get(device=0):
307
322
 
308
323
 
309
324
  def rsmi_dev_node_id_get(device=0):
310
- if not rocmsmiLib:
311
- raise ROCMSMIError(ROCMSMI_ERROR_UNINITIALIZED)
312
-
313
325
  c_node_id = c_uint32()
314
- ret = rocmsmiLib.rsmi_dev_node_id_get(device, byref(c_node_id))
326
+ fn = _rocmsmiGetFunctionPointer("rsmi_dev_node_id_get")
327
+ ret = fn(device, byref(c_node_id))
315
328
  _rocmsmiCheckReturn(ret)
316
329
  return c_node_id.value
317
330
 
318
331
 
319
332
  def rsmi_dev_pci_id_get(device=0):
320
- if not rocmsmiLib:
321
- raise ROCMSMIError(ROCMSMI_ERROR_UNINITIALIZED)
322
-
333
+ fn = _rocmsmiGetFunctionPointer("rsmi_dev_pci_id_get")
323
334
  c_pci_id = c_uint64()
324
- ret = rocmsmiLib.rsmi_dev_pci_id_get(device, byref(c_pci_id))
335
+ ret = fn(device, byref(c_pci_id))
325
336
  _rocmsmiCheckReturn(ret)
326
337
 
327
338
  return str_bdfid(c_pci_id.value)
@@ -339,22 +350,18 @@ def str_bdfid(bdfid: int) -> str:
339
350
 
340
351
 
341
352
  def rsmi_topo_get_numa_node_number(device=0):
342
- if not rocmsmiLib:
343
- raise ROCMSMIError(ROCMSMI_ERROR_UNINITIALIZED)
344
-
345
353
  c_numa_node = c_uint32()
346
- ret = rocmsmiLib.rsmi_topo_get_numa_node_number(device, byref(c_numa_node))
354
+ fn = _rocmsmiGetFunctionPointer("rsmi_topo_get_numa_node_number")
355
+ ret = fn(device, byref(c_numa_node))
347
356
  _rocmsmiCheckReturn(ret)
348
357
  return c_numa_node.value
349
358
 
350
359
 
351
360
  def rsmi_topo_get_link_type(device_a=0, device_b=0):
352
- if not rocmsmiLib:
353
- raise ROCMSMIError(ROCMSMI_ERROR_UNINITIALIZED)
354
-
355
361
  c_hops = c_uint64()
356
362
  c_type = c_uint32()
357
- ret = rocmsmiLib.rsmi_topo_get_link_type(
363
+ fn = _rocmsmiGetFunctionPointer("rsmi_topo_get_link_type")
364
+ ret = fn(
358
365
  device_a,
359
366
  device_b,
360
367
  byref(c_hops),
@@ -365,11 +372,9 @@ def rsmi_topo_get_link_type(device_a=0, device_b=0):
365
372
 
366
373
 
367
374
  def rsmi_topo_get_link_weight(device_a=0, device_b=0):
368
- if not rocmsmiLib:
369
- raise ROCMSMIError(ROCMSMI_ERROR_UNINITIALIZED)
370
-
371
375
  c_weight = c_uint64()
372
- ret = rocmsmiLib.rsmi_topo_get_link_weight(
376
+ fn = _rocmsmiGetFunctionPointer("rsmi_topo_get_link_weight")
377
+ ret = fn(
373
378
  device_a,
374
379
  device_b,
375
380
  byref(c_weight),
@@ -379,11 +384,9 @@ def rsmi_topo_get_link_weight(device_a=0, device_b=0):
379
384
 
380
385
 
381
386
  def rsmi_is_p2p_accessible(device_a=0, device_b=0):
382
- if not rocmsmiLib:
383
- raise ROCMSMIError(ROCMSMI_ERROR_UNINITIALIZED)
384
-
385
387
  c_accessible = c_bool()
386
- ret = rocmsmiLib.rsmi_is_P2P_accessible(
388
+ fn = _rocmsmiGetFunctionPointer("rsmi_is_P2P_accessible")
389
+ ret = fn(
387
390
  device_a,
388
391
  device_b,
389
392
  byref(c_accessible),