Skip to content

Commit 265c50f

Browse files
committed
Make gpustat.nvml compatible with a third-party fork of pynvml (#153)
An un-official distribution of the pynvml package provided by @gpuopenanalytics/pynvml was causing an incompatibility issue, where gpustat.nvml fails to import. Although the official and correct pynvml packages should be installed, but wild users' python environments can be easily messed up by unawaringly installing the problematic, unofficial pynvml package. gpustat can support this third-party pynvml by directly importing the low-level pynvml.nvml package (which should be exactly the same as an official pynvml.py). This is a quickfix that relies on the implementation detail of a third-party package, but nevertheless it should be a good enough workaround solution for many users in practice. (cherry picked from commit 7c09a0f, backported to 1.1.x)
1 parent 1a627cb commit 265c50f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

gpustat/nvml.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
raise ImportError("pynvml library is outdated.")
2828

2929
if not hasattr(pynvml, '_nvmlGetFunctionPointer'):
30-
raise ImportError("pynvml appears to be a non-official package.")
30+
# Unofficial pynvml from @gpuopenanalytics/pynvml, see #153
31+
import pynvml.nvml as pynvml
3132

3233
except (ImportError, SyntaxError, RuntimeError) as e:
3334
_pynvml = sys.modules.get('pynvml', None)

0 commit comments

Comments
 (0)