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

perf: Improve performance by reducing redundant pynvml.nvmlInit call #166

Merged
merged 1 commit into from
Nov 24, 2023

Conversation

wookayin
Copy link
Owner

@wookayin wookayin commented Nov 22, 2023

perf: Call nvmlInit() and nvmlShutdown() only once (fixes #54)

Lots of time is spent on nvmlInit() and nvmlShutdown() for each
new_query call. When running in a loop mode (-i), we do not need to
initialize and shutdown the nvml library because nvml APIs will be used
throughout the lifespan of the gpustat process.

Upon importing gpustat.pynvml, nvmlInit() will always be called.

Copy link
Collaborator

@Stonesjtu Stonesjtu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great feature!
Ship it!

Lots of time is spent on nvmlInit() and nvmlShutdown() for each
new_query call. When running in a loop mode (-i), we do not need to
initialize and shutdown the nvml library because nvml APIs will be used
throughout the lifespan of the gpustat process.

Upon importing `gpustat.pynvml`, nvmlInit() will always be called.
@wookayin wookayin changed the title perf: Improve performance by reducing redundant pynvml call perf: Improve performance by reducing redundant pynvml.nvmlInit call Nov 24, 2023
@wookayin wookayin merged commit 313b58d into master Nov 24, 2023
26 checks passed
@wookayin wookayin deleted the improve-perf branch November 24, 2023 07:50
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

Successfully merging this pull request may close these issues.

use too much CPU resource
2 participants