gpuopenanalytics / pynvml

Provide Python access to the NVML library for GPU diagnostics
BSD 3-Clause "New" or "Revised" License
220 stars 31 forks source link

Fix version check test #23

Closed ksangeek closed 4 years ago

ksangeek commented 4 years ago
  1. Proposed fix for https://github.com/gpuopenanalytics/pynvml/issues/22 where I have removed the typecast of the version to float, as that does not work with driver versions like 440.33.01 or 418.87.00. I have modified the version check test case to check if the major version number is greater than 0. Please let me know if there are suggestions to improve the test.
  2. I have also modified the test_nvmlSystemGetNVMLVersion to test the API nvmlSystemGetNVMLVersion() instead of nvmlSystemGetDriverVersion(), which I think it was intended to. Else test_nvmlSystemGetNVMLVersion() and test_nvmlSystemGetDriverVersion() were testing the same API.
ksangeek commented 4 years ago

Unit test results -

Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 19:18:58)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pynvml
>>> pynvml.nvmlInit()
>>> pynvml.nvmlSystemGetDriverVersion().decode()
'440.33.01'
>>> vsn = pynvml.nvmlSystemGetDriverVersion().decode()
>>> print('[Driver Version: '+vsn+']', end =' ')
[Driver Version: 440.33.01] >>>
>>> int(vsn.split('.')[0])
440
>>> int(vsn.split('.')[0]) > 0.0
True

>>> vsn = pynvml.nvmlSystemGetNVMLVersion().decode()
>>> print('[NVML Version: '+vsn+']', end =' ')
[NVML Version: 10.440.33.01] >>>
>>> int(vsn.split('.')[0])
10
>>> int(vsn.split('.')[0]) > 0.0
True
rjzamora commented 4 years ago

LGTM - Thanks @ksangeek !