Skip to content

Commit 54e2f49

Browse files
committed
supress warning
1 parent 0b1bb68 commit 54e2f49

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

benches/monitor.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,31 @@
1414
_NV_OK = False
1515
pynvml = None
1616
if not (os.environ.get('LLM_BENCH_SKIP_GPU') == '1'):
17+
# prefer newer package name if available
1718
try:
18-
import pynvml
19+
import nvidia_ml_py as nvml_pkg # type: ignore
1920
try:
20-
pynvml.nvmlInit()
21+
nvml_pkg.nvmlInit()
22+
pynvml = nvml_pkg
2123
_NV_OK = True
2224
except Exception:
2325
_NV_OK = False
2426
except Exception:
25-
pynvml = None # type: ignore
26-
_NV_OK = False
27+
try:
28+
# suppress deprecation FutureWarning from pynvml package if present
29+
import warnings
30+
with warnings.catch_warnings():
31+
warnings.simplefilter('ignore', FutureWarning)
32+
import pynvml as nvml_pkg # type: ignore
33+
try:
34+
nvml_pkg.nvmlInit()
35+
pynvml = nvml_pkg
36+
_NV_OK = True
37+
except Exception:
38+
_NV_OK = False
39+
except Exception:
40+
pynvml = None # type: ignore
41+
_NV_OK = False
2742

2843

2944
@dataclass

0 commit comments

Comments
 (0)