Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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