Skip to content

[RFC]: copy pynvml code into vllm codebase #12977

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

Closed
1 task done
youkaichao opened this issue Feb 9, 2025 · 4 comments
Closed
1 task done

[RFC]: copy pynvml code into vllm codebase #12977

youkaichao opened this issue Feb 9, 2025 · 4 comments
Labels

Comments

@youkaichao
Copy link
Member

Motivation.

We have suffered a lot from the module pynvml recently, see #12847 for example.

libnvml.so is the library behind nvidia-smi, and pynvml is a Python wrapper around it. We use it to get GPU status without initializing CUDA context in the current process.
Historically, there are two packages that provide a module named pynvml:

  • nvidia-ml-py (https://pypi.org/project/nvidia-ml-py/): The official wrapper. It is a dependency of vLLM, and is installed when users install vLLM. It provides a Python module named pynvml.
  • pynvml (https://pypi.org/project/pynvml/): An unofficial wrapper. Prior to version 12.0, it also provides a Python module pynvml, and therefore conflicts with the official one. What's worse, the module is a Python package, and has higher priority than the official one which is a standalone Python file. This causes errors when both of them are installed. Starting from version 12.0, it migrates to a new module named pynvml_utils to avoid the conflict.

To make vLLM work, we have to make sure, there's no pynvml package, or the pynvml package has version 12.0 or higher. However, neither of them is a doable solution:

To summarize, we are in a dependency hell due to the historical confusing packages.

Proposed Change.

To solve the problem, I propose to copy the code from nvidia-ml-py into vLLM, and use vllm.third_party.pynvml to import it. See #12963 for the prototype.

The solution is only to rescue us from the dependency hell. We don't need to maintain the code. If there are bugfixes in nvidia-ml-py in the future, we can periodically sync the code.

This is the first time we copy a whole package into vllm, so I'm creating a separate directory vllm/third_party to hold the code.

This RFC is for future reference, when we need to copy code into vllm/third_party.

Feedback Period.

No response

CC List.

No response

Any Other Things.

No response

Before submitting a new issue...

  • Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.
@youkaichao youkaichao added the RFC label Feb 9, 2025
@youkaichao
Copy link
Member Author

The approach I take here, is inspired by ray, as I found they also copy pynvml into their codebase, see https://github.com/ray-project/ray/blob/master/python/ray/_private/thirdparty/pynvml/pynvml.py .

@houseroad
Copy link
Collaborator

Actually, it's not a bad idea, especially only need to copy one file. PyTorch also leverage some similar ideas to solve some build or deps issue, such as using miniz as zip library, etc.

@noooop
Copy link
Contributor

noooop commented Feb 10, 2025

This should have been done a long time ago

@DarkLight1337
Copy link
Member

Closing as completed by #12963

markmc added a commit to markmc/vllm that referenced this issue Mar 13, 2025
This code is copied from nvidia-ml-py and as per vllm-project#12977 we will need to
periodically sync the code to pick up bugfixes.

Signed-off-by: Mark McLoughlin <[email protected]>
liuzijing2014 pushed a commit to liuzijing2014/vllm that referenced this issue Mar 26, 2025
This code is copied from nvidia-ml-py and as per vllm-project#12977 we will need to
periodically sync the code to pick up bugfixes.

Signed-off-by: Mark McLoughlin <[email protected]>
liuzijing2014 pushed a commit to liuzijing2014/vllm that referenced this issue Apr 3, 2025
This code is copied from nvidia-ml-py and as per vllm-project#12977 we will need to
periodically sync the code to pick up bugfixes.

Signed-off-by: Mark McLoughlin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants