diff --git a/javascript/nvml.js b/javascript/nvml.js
new file mode 100644
index 000000000..6f4dd2d56
--- /dev/null
+++ b/javascript/nvml.js
@@ -0,0 +1,65 @@
+let nvmlInterval = true; // eslint-disable-line prefer-const
+let nvmlEl = null;
+let nvmlTable = null;
+
+async function updateNVML() {
+ try {
+ const res = await fetch('/sdapi/v1/nvml');
+ console.log('HERE1', res);
+ if (!res.ok) {
+ clearInterval(nvmlInterval);
+ nvmlEl.style.display = 'none';
+ return;
+ }
+ const data = await res.json();
+ console.log('HERE2', data);
+ if (!data) {
+ clearInterval(nvmlInterval);
+ nvmlEl.style.display = 'none';
+ return;
+ }
+ const nvmlTbody = nvmlTable.querySelector('tbody');
+ for (const gpu of data) {
+ const rows = `
+
| GPU | ${gpu.name} |
+ | Driver | ${gpu.version.driver} |
+ | VBIOS | ${gpu.version.vbios} |
+ | ROM | ${gpu.version.rom} |
+ | Driver | ${gpu.version.driver} |
+ | PCI | Gen.${gpu.pci.link} x${gpu.pci.width} |
+ | Memory | ${gpu.memory.used}Mb / ${gpu.memory.total}Mb |
+ | Clock | ${gpu.clock.gpu[0]}Mhz / ${gpu.clock.gpu[1]}Mhz |
+ | Power | ${gpu.power[0]}W / ${gpu.power[1]}W |
+ | Load GPU | ${gpu.load.gpu}% |
+ | Load Memory | ${gpu.load.memory}% |
+ | Temperature | ${gpu.load.temp}°C |
+ | Fans | ${gpu.load.fan}% |
+ | State | ${gpu.state} |
+ `;
+ nvmlTbody.innerHTML = rows;
+ }
+ nvmlEl.style.display = 'block';
+ } catch (e) {
+ clearInterval(nvmlInterval);
+ nvmlEl.style.display = 'none';
+ }
+}
+
+async function initNVML() {
+ nvmlEl = document.createElement('div');
+ nvmlEl.className = 'nvml';
+ nvmlEl.id = 'nvml';
+ nvmlTable = document.createElement('table');
+ nvmlTable.className = 'nvml-table';
+ nvmlTable.id = 'nvml-table';
+ nvmlTable.innerHTML = `
+ | |
+
+ `;
+ nvmlEl.appendChild(nvmlTable);
+ gradioApp().appendChild(nvmlEl);
+ log('initNVML');
+ // nvmlInterval = setInterval(updateNVML, 1000);
+}
+
+onUiLoaded(initNVML);
diff --git a/javascript/style.css b/javascript/style.css
index c79c48f62..7ba4dc7c8 100644
--- a/javascript/style.css
+++ b/javascript/style.css
@@ -326,6 +326,19 @@ div.controlnet_main_options { display: grid; grid-template-columns: 1fr 1fr; gri
/* custom component */
.folder-selector textarea { height: 2em !important; padding: 6px !important; }
+.nvml {
+ position: fixed;
+ top: 100px;
+ left: 100px;
+ background: var(--background-fill-primary);
+ border: 1px solid var(--button-primary-border-color);
+ padding: 6px;
+ color: var(--button-primary-text-color);
+ font-size: 0.7em;
+ z-index: 50;
+ font-family: monospace;
+ display: none;
+}
/* Workaround for Gradio dropdowns capturing clicks during and after fadeout */
.gradio-dropdown > label > div > div:first-child:not(.showOptions) ~ ul.options { pointer-events: none; }
diff --git a/modules/api/nvml.py b/modules/api/nvml.py
index e2150de6c..b7bb3ddd5 100644
--- a/modules/api/nvml.py
+++ b/modules/api/nvml.py
@@ -76,8 +76,8 @@ def get_nvml():
'memory': [nv.nvmlDeviceGetClockInfo(dev, 2), nv.nvmlDeviceGetMaxClockInfo(dev, 2)],
},
'load': {
- 'gpu': nv.nvmlDeviceGetUtilizationRates(dev).gpu,
- 'memory': nv.nvmlDeviceGetUtilizationRates(dev).memory,
+ 'gpu': round(nv.nvmlDeviceGetUtilizationRates(dev).gpu),
+ 'memory': round(nv.nvmlDeviceGetUtilizationRates(dev).memory),
'temp': nv.nvmlDeviceGetTemperature(dev, 0),
'fan': nv.nvmlDeviceGetFanSpeed(dev),
},