Created
December 12, 2019 11:10
-
-
Save jacobtomlinson/2a72321652fcd216543ae0c6150e9846 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gpu(doc): | |
fig = figure(title="GPU Utilization", sizing_mode="stretch_both", x_range=[0, 100]) | |
def get_utilization(): | |
return [ | |
pynvml.nvmlDeviceGetUtilizationRates(gpu_handles[i]).gpu | |
for i in range(ngpus) | |
] | |
gpu = get_utilization() | |
y = list(range(len(gpu))) | |
source = ColumnDataSource({"right": y, "gpu": gpu}) | |
mapper = LinearColorMapper(palette=all_palettes["RdYlBu"][4], low=0, high=100) | |
fig.hbar( | |
source=source, | |
y="right", | |
right="gpu", | |
height=0.8, | |
color={"field": "gpu", "transform": mapper}, | |
) | |
fig.toolbar_location = None | |
doc.title = "GPU Utilization [%]" | |
doc.add_root(fig) | |
def cb(): | |
source.data.update({"gpu": get_utilization()}) | |
doc.add_periodic_callback(cb, 200) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment