Skip to content

Commit

Permalink
Make gpustat.nvml compatible with a third-party fork of pynvml (#153)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wookayin committed Jun 1, 2023
1 parent e6bf58f commit 7c09a0f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gpustat/nvml.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
raise ImportError("pynvml library is outdated.")

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

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

0 comments on commit 7c09a0f

Please sign in to comment.