Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make dependency on pynvml optional #378

Closed
grothesque opened this issue Mar 29, 2022 · 9 comments
Closed

Make dependency on pynvml optional #378

grothesque opened this issue Mar 29, 2022 · 9 comments

Comments

@grothesque
Copy link

It seems to me that the dependency on pynvml could be made optional. I just installed scalene from git (version 1.1.15-1525-gf05850d) and it did not want to run due to missing pynvml. So I uncommented the line import pynvml at the top of the file scalene/scalene_gpu.py and it seems to work now.

It seems unnecessary to have a hard dependency where a recommendation would suffice. Specifically, a majority of python profile users is most likely not doing Nvidia GPU programming.

@emeryberger
Copy link
Member

What system are you running on? (Also, where exactly would a recommendation fit in? I worry this would add confusion). (In principle, I don't see why it didn't install pynvml as it is in requirements.txt and setup.py...)

@grothesque
Copy link
Author

I'm running Debian GNU/Linux. I installed scalene semi-manually without using pip. (I avoid using pip if I can help it for several reasons that are off-topic here.)

My point is that scalene is a general-purpose profiler, and pynvml is a specific library that is only of specialist interest (by far most Python programmers never do Nvidia GPU programming).

Moreover, while scalene is an open-source tool for an open-source language that is firmly embedded in the open-source community, pynvml is only useful for people who run Nvidia's non-free drivers.

@ianozsvald
Copy link

Hi @emeryberger I've tagged this issue against the Dask issue 5768 (above), by installing Dask + Scalene we get a non-functioning Dask.
I've tried installing scalene and uninstalling pynvml (I don't have a GPU to profile) but then scalene fails. I'd +1 making pynvml an optional dependency. The bug in Dask can probably be solved but having tools increasingly widen their dependency set can make having reproducible and stable environments a growing challenge. The fact that Dask (somehow) optionally uses pynvml is odd for sure as it isn't installed by the standard "complete" Dask installer.

@emeryberger
Copy link
Member

OK, what is the desired behavior? I can remove it from requirements and setup; I can then have Scalene print a warning that pynvml needs to be installed (on non-Apple systems) to profile NVIDIA GPUs, if any (this might be annoying to always see when running Scalene - alternative approaches welcome).

@ianozsvald
Copy link

The fact that scalene uses it isn't the big issue (for me), it is the fact that Dask silently uses it if present but doesn't install it, and in that scenario Dask fails for several of us - for me that's a killer (and cost me a few frantic hours last night as I prepare to run a course). That's not scelene's fault.
For scalene I'd say have two install options (Dask has several: https://docs.dask.org/en/stable/install.html#pip ) from "core" to "everything", where maybe GPU stuff isn't in the core.
I've seen other libraries depend on both Dask & Ray (both huge similar parallelisation libraries) and suddenly the bloat grows horribly with strange dependency issues due to the depth of the dependency tree. Probably it is best to avoid that for everyone's sanity, but it does make a bit more work for you.

@emeryberger
Copy link
Member

@ianozsvald I recently removed the dependency on nvidia-ml-py; can you verify that you still have the same problem with pynvml?

@ianozsvald
Copy link

@emeryberger on a fresh install everything looks good, thanks. I built a fresh conda Python 3.9 environment, installed Dask and my usual higher performance tools, then installed your git version of Scalene and Dask is able to start a client without a failure, many thanks.

To be clear - pynvml is installed by Scalene, nvidia_ml_py is not installed and it looks like that was the issue (at least for me on Linux with Dask).

(course_sc)...$ python3 -m pip install git+https://github.com/plasma-umass/scalene
Collecting git+https://github.com/plasma-umass/scalene
  Cloning https://github.com/plasma-umass/scalene to /tmp/pip-req-build-p11lz4au
  Running command git clone --filter=blob:none --quiet https://github.com/plasma-umass/scalene /tmp/pip-req-build-p11lz4au
  Resolved https://github.com/plasma-umass/scalene to commit 7279a399b38e00d63e7264cfc0662615d81c25f2
  Preparing metadata (setup.py) ... done
Requirement already satisfied: rich>=9.2.0 in /home/ian/miniconda3/envs/course_sc/lib/python3.9/site-packages (from scalene==1.5.5) (12.1.0)
Requirement already satisfied: cloudpickle>=1.5.0 in /home/ian/miniconda3/envs/course_sc/lib/python3.9/site-packages (from scalene==1.5.5) (2.0.0)
Requirement already satisfied: numpy in /home/ian/miniconda3/envs/course_sc/lib/python3.9/site-packages (from scalene==1.5.5) (1.21.5)
Collecting pynvml>=11.0.0
  Downloading pynvml-11.4.1-py3-none-any.whl (46 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 47.0/47.0 KB 1.8 MB/s eta 0:00:00
Requirement already satisfied: pygments<3.0.0,>=2.6.0 in /home/ian/miniconda3/envs/course_sc/lib/python3.9/site-packages (from rich>=9.2.0->scalene==1.5.5) (2.11.2)
Requirement already satisfied: commonmark<0.10.0,>=0.9.0 in /home/ian/miniconda3/envs/course_sc/lib/python3.9/site-packages (from rich>=9.2.0->scalene==1.5.5) (0.9.1)
Building wheels for collected packages: scalene
  Building wheel for scalene (setup.py) ... done
  Created wheel for scalene: filename=scalene-1.5.5-cp39-cp39-linux_x86_64.whl size=598602 sha256=3933f8769682bad9a0bdd83ee251b5d6124000ff281f664b663a7b3254001cfd
  Stored in directory: /tmp/pip-ephem-wheel-cache-9jwm6z6t/wheels/b5/9a/6b/99f8971bd588f69b6774efcd6235b5c3297253f66d396e1fb5
Successfully built scalene
Installing collected packages: pynvml, scalene
Successfully installed pynvml-11.4.1 scalene-1.5.5
(course_sc) $ ipython
Python 3.9.12 | packaged by conda-forge | (main, Mar 24 2022, 23:25:59) 
Type 'copyright', 'credits' or 'license' for more information
IPython 8.2.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import pynvml

In [2]: import dask.distributed

In [3]: dask.distributed.Client()
/home/ian/miniconda3/envs/course_sc/lib/python3.9/site-packages/distributed/node.py:177: UserWarning: Port 8787 is already in use.
Perhaps you already have a cluster running?
Hosting the HTTP server on port 41491 instead
  warnings.warn(
Out[3]: <Client: 'tcp://127.0.0.1:45627' processes=4 threads=8, memory=31.12 GiB>

@emeryberger
Copy link
Member

Thanks! The latest release removes the nvidia-ml-py dependency.

@emeryberger
Copy link
Member

I am closing this since I think the current behavior is ideal (now that it isn't interfering with Dask): Scalene silently ignores GPUs when they aren't found, and uses them automatically when found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants