Skip to content

Instantly share code, notes, and snippets.

@jacobtomlinson
Created December 12, 2019 11:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jacobtomlinson/2a72321652fcd216543ae0c6150e9846 to your computer and use it in GitHub Desktop.
Save jacobtomlinson/2a72321652fcd216543ae0c6150e9846 to your computer and use it in GitHub Desktop.
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