Skip to content

Commit

Permalink
Do not allow non-official pynvml library (#153)
Browse files Browse the repository at this point in the history
Revert "Make gpustat.nvml compatible with a third-party fork of pynvml"

This reverts commit 7c09a0f.

gpustat v1.1.1 allowed the problematic 'pynvml' package to be used
as a workaround, but this still causes many problems (e.g., #168).
Only the official nvidia-ml-py can be used with gpustat.

See #153, #168
  • Loading branch information
wookayin committed Jan 12, 2024
1 parent 7f6e3ee commit 3220e99
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Changelog for `gpustat`

## v1.2 (Unreleased)

- Non-official pynvml is no longer allowed (#153)
- Internal refactoring for display and formatting
- Improve CI and release workflow
- Support Python 3.12 by running CI tests.
Expand Down
21 changes: 14 additions & 7 deletions gpustat/nvml.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@
raise ImportError("pynvml library is outdated.")

if not hasattr(pynvml, '_nvmlGetFunctionPointer'):
# Unofficial pynvml from @gpuopenanalytics/pynvml, see #153
import pynvml.nvml as pynvml # type: ignore
raise ImportError(
"""pynvml appears to be a non-official package.
The PyPI package `pynvml` should not be used.
Please use the official NVIDIA bindings `nvidia-ml-py`.
""")

except (ImportError, SyntaxError, RuntimeError) as e:
_pynvml = sys.modules.get('pynvml', None)
Expand All @@ -40,9 +44,12 @@
"""\
pynvml is missing or an outdated version is installed.
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
gpustat requires nvidia-ml-py>=11.450.129, and the *official* NVIDIA python bindings
should be used; neither nvidia-ml-py3 nor gpuopenanalytics/pynvml is compatible.
For more details, please refer to:
https://github.com/wookayin/gpustat/issues/107
https://github.com/wookayin/gpustat/issues/153
The root cause: """ + str(e) +
"""
Expand All @@ -51,11 +58,11 @@
"""
-----------------------------------------------------------
Please reinstall `gpustat`:
(Suggested Fix) Please reinstall `gpustat`:
$ pip install --force-reinstall gpustat
If it still does not fix the problem, please uninstall pynvml packages and reinstall nvidia-ml-py manually:
If it still does not fix the problem, please uninstall `pynvml` packages and reinstall `nvidia-ml-py` manually:
$ pip uninstall nvidia-ml-py3 pynvml
$ pip install --force-reinstall --ignore-installed 'nvidia-ml-py'
Expand Down

0 comments on commit 3220e99

Please sign in to comment.