Skip to content

Commit

Permalink
Show error messages when incorrect pynvml is installed (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
wookayin committed May 17, 2023
1 parent 50779ad commit e6bf58f
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions gpustat/nvml.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
# Requires nvidia-ml-py >= 11.450.129, < 11.510.69
hasattr(pynvml, 'nvmlDeviceGetComputeRunningProcesses_v2')
) and not ALLOW_LEGACY_PYNVML:
raise RuntimeError("pynvml library is outdated.")
raise ImportError("pynvml library is outdated.")

if not hasattr(pynvml, '_nvmlGetFunctionPointer'):
raise ImportError("pynvml appears to be a non-official package.")

except (ImportError, SyntaxError, RuntimeError) as e:
_pynvml = sys.modules.get('pynvml', None)
Expand All @@ -33,9 +36,13 @@
"""\
pynvml is missing or an outdated version is installed.
We require nvidia-ml-py>=11.450.129, and nvidia-ml-py3 shall not be used.
We require nvidia-ml-py>=11.450.129, and the official NVIDIA python bindings
should be used; neither nvidia-ml-py3 nor gpuopenanalytics/pynvml.
For more details, please refer to: https://github.com/wookayin/gpustat/issues/107
The root cause: """ + str(e) +
"""
Your pynvml installation: """ + repr(_pynvml) +
"""
Expand All @@ -44,10 +51,10 @@
$ pip install --force-reinstall gpustat
If it still does not fix the problem, please manually fix nvidia-ml-py installation:
If it still does not fix the problem, please uninstall pynvml packages and reinstall nvidia-ml-py manually:
$ pip uninstall nvidia-ml-py3
$ pip install --force-reinstall 'nvidia-ml-py<=11.495.46'
$ pip uninstall nvidia-ml-py3 pynvml
$ pip install --force-reinstall --ignore-installed 'nvidia-ml-py'
""")) from e


Expand Down

0 comments on commit e6bf58f

Please sign in to comment.