[GH-ISSUE #119] [Question] How snapshot could be used #71

Closed
opened 2026-05-05 03:24:30 -06:00 by gitea-mirror · 2 comments
Owner

Originally created by @Xiang-cd on GitHub (Jan 30, 2024).
Original GitHub issue: https://github.com/XuehaiPan/nvitop/issues/119

Originally assigned to: @XuehaiPan on GitHub.

Required prerequisites

  • I have read the documentation https://nvitop.readthedocs.io.
  • I have searched the Issue Tracker that this hasn't already been reported. (comment there if it has.)
  • I have tried the latest version of nvitop in a new isolated virtual environment.

Questions

thank you for your great work! I've seen the as_snapshot function, but I was wondering how the snapshot could be used?
is the snapshot resumable? because I didn't see the resume interface.

Originally created by @Xiang-cd on GitHub (Jan 30, 2024). Original GitHub issue: https://github.com/XuehaiPan/nvitop/issues/119 Originally assigned to: @XuehaiPan on GitHub. ### Required prerequisites - [X] I have read the documentation <https://nvitop.readthedocs.io>. - [X] I have searched the [Issue Tracker](https://github.com/XuehaiPan/nvitop/issues) that this hasn't already been reported. (comment there if it has.) - [ ] I have tried the latest version of nvitop in a new isolated virtual environment. ### Questions thank you for your great work! I've seen the as_snapshot function, but I was wondering how the snapshot could be used? is the snapshot resumable? because I didn't see the resume interface.
gitea-mirror 2026-05-05 03:24:30 -06:00
Author
Owner

@XuehaiPan commented on GitHub (Jan 30, 2024):

@Xiang-cd Thanks for raising this.

The Device / GpuProcess instance is live object to get the latest metrics via method calls. E.g.:

device = Device(0)

device.gpu_utilization()  # -> 96
time.sleep(1)
device.gpu_utilization()  # -> 80  # the latest value from a new NVML API call

Once it is converted to snapshot, the metrics are forzen. The metrcis values are obtained at the time you call as_snapshot().

device = Device(0)

snapshot = device.as_snapshot()
snapshot.gpu_utilization  # -> 94
time.sleep(1)
snapshot.gpu_utilization  # -> 94 (always the freezed value)

You can access the device object via:

snapshot = device.as_snapshot()

snapshot.real  # -> Device(...)

# Get a new snapshot
snapshot = snapshot.real.as_snapshot()
# or
snapshot = device.as_snapshot()
<!-- gh-comment-id:1917152310 --> @XuehaiPan commented on GitHub (Jan 30, 2024): @Xiang-cd Thanks for raising this. The `Device` / `GpuProcess` instance is live object to get the latest metrics via method calls. E.g.: ```python device = Device(0) device.gpu_utilization() # -> 96 time.sleep(1) device.gpu_utilization() # -> 80 # the latest value from a new NVML API call ``` Once it is converted to snapshot, the metrics are forzen. The metrcis values are obtained at the time you call `as_snapshot()`. ```python device = Device(0) snapshot = device.as_snapshot() snapshot.gpu_utilization # -> 94 time.sleep(1) snapshot.gpu_utilization # -> 94 (always the freezed value) ``` You can access the device object via: ```python snapshot = device.as_snapshot() snapshot.real # -> Device(...) # Get a new snapshot snapshot = snapshot.real.as_snapshot() # or snapshot = device.as_snapshot() ```
Author
Owner

@Xiang-cd commented on GitHub (Feb 11, 2024):

thank you, so the snapshot is not a context containing all memory content and register status that could move all context of one device to another device?

<!-- gh-comment-id:1937461213 --> @Xiang-cd commented on GitHub (Feb 11, 2024): thank you, so the snapshot is not a context containing all memory content and register status that could move all context of one device to another device?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/nvitop#71
No description provided.