Skip to content

Commit 73fe30f

Browse files
committed
[fix] export failure with CUDA driver < 526 and pynvml>=11.5.0
- There is a bug that was fixed in the 526 driver release. For older driver versions the recommendation is to downgrade the pynvml version to 11.4.0 and use 11.5.0 only for drivers after 526. Uses the legacy pynvml memory usage function even with pynvml 11.5.0 if the driver version is older than 526. Mentioned in the issue as well: NVIDIA#808 (comment)
1 parent 06c0e9b commit 73fe30f

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

tensorrt_llm/profiler.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,19 @@
4444
"A required package 'pynvml' is not installed. Will not "
4545
"monitor the device memory usages. Please install the package "
4646
"first, e.g, 'pip install pynvml>=11.5.0'.")
47-
elif pynvml.__version__ < '11.5.0':
48-
logger.warning(f'Found pynvml=={pynvml.__version__}. Please use '
49-
f'pynvml>=11.5.0 to get accurate memory usage')
50-
# Support legacy pynvml. Note that an old API could return
51-
# wrong GPU memory usage.
52-
_device_get_memory_info_fn = pynvml.nvmlDeviceGetMemoryInfo
5347
else:
54-
_device_get_memory_info_fn = partial(pynvml.nvmlDeviceGetMemoryInfo,
55-
version=pynvml.nvmlMemory_v2)
48+
pynvml.nvmlInit()
49+
driver_version = pynvml.nvmlSystemGetDriverVersion()
50+
if pynvml.__version__ < '11.5.0' or driver_version < '526':
51+
logger.warning(f'Found pynvml=={pynvml.__version__} and cuda driver version {driver_version}.'
52+
' Please use pynvml>=11.5.0 and cuda driver>=526 to get accurate memory usage')
53+
# Support legacy pynvml. Note that an old API could return
54+
# wrong GPU memory usage.
55+
_device_get_memory_info_fn = pynvml.nvmlDeviceGetMemoryInfo
56+
else:
57+
_device_get_memory_info_fn = partial(pynvml.nvmlDeviceGetMemoryInfo,
58+
version=pynvml.nvmlMemory_v2)
59+
pynvml.nvmlShutdown()
5660

5761

5862
class Timer:

0 commit comments

Comments
 (0)