Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add rocm-smi #960

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ changes!):
- added printer: get information from detected printers
- added usb: get detailed usb controller and device information
- added wifi interfaces and connections: extended wifi information
- **added rocm-smi support**: get detailed information about AMD GPUs using ROCm
- better uuid function to get unique hardware and OS UUIDs
- better/extended cpu info detection
- better/extended system info detection
Expand Down
26 changes: 8 additions & 18 deletions docs/graphics.html
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ <h2>Graphics Controllers, Displays</h2>
<td></td>
<td>X</td>
<td></td>
<td>(optional nvidia-smi) - name</td>
<td>(optional rocm-smi) - name</td>
</tr>
<tr>
<td></td>
Expand All @@ -235,17 +235,7 @@ <h2>Graphics Controllers, Displays</h2>
<td></td>
<td>X</td>
<td></td>
<td>(optional nvidia-smi) - PCI bus ID</td>
</tr>
<tr>
<td></td>
<td>...[0].fanSpeed</td>
<td>X</td>
<td></td>
<td></td>
<td>X</td>
<td></td>
<td>(optional nvidia-smi) - fan speed</td>
<td>(optional rocm-smi) - PCI bus ID</td>
</tr>
<tr>
<td></td>
Expand All @@ -255,7 +245,7 @@ <h2>Graphics Controllers, Displays</h2>
<td></td>
<td>X</td>
<td></td>
<td>(optional nvidia-smi) - memory total</td>
<td>(optional rocm-smi) - memory total</td>
</tr>
<tr>
<td></td>
Expand All @@ -265,7 +255,7 @@ <h2>Graphics Controllers, Displays</h2>
<td></td>
<td>X</td>
<td></td>
<td>(optional nvidia-smi) - memory used</td>
<td>(optional rocm-smi) - memory used</td>
</tr>
<tr>
<td></td>
Expand Down Expand Up @@ -305,7 +295,7 @@ <h2>Graphics Controllers, Displays</h2>
<td></td>
<td>X</td>
<td></td>
<td>(optional nvidia-smi) - temperature GPU</td>
<td>(optional rocm-smi) - temperature GPU</td>
</tr>
<tr>
<td></td>
Expand All @@ -325,7 +315,7 @@ <h2>Graphics Controllers, Displays</h2>
<td></td>
<td>X</td>
<td></td>
<td>(optional nvidia-smi) - power draw</td>
<td>(optional rocm-smi) - power draw</td>
</tr>
<tr>
<td></td>
Expand All @@ -345,7 +335,7 @@ <h2>Graphics Controllers, Displays</h2>
<td></td>
<td>X</td>
<td></td>
<td>(optional nvidia-smi) - clock core</td>
<td>(optional rocm-smi) - core clock</td>
</tr>
<tr>
<td></td>
Expand All @@ -355,7 +345,7 @@ <h2>Graphics Controllers, Displays</h2>
<td></td>
<td>X</td>
<td></td>
<td>(optional nvidia-smi) - clock memory</td>
<td>(optional rocm-smi) - memory clock</td>
</tr>
<tr>
<td></td>
Expand Down
57 changes: 57 additions & 0 deletions lib/graphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,63 @@ function graphics(callback) {
return displays;
}

function getRocmSmi() {
if (_linux) {
return 'rocm-smi';
}
return '';
}

function rocmSmi(options) {
const rocmSmiExe = getRocmSmi();
options = options || {};
if (rocmSmiExe) {
const rocmSmiOpts = '--showall --json';
const cmd = rocmSmiExe + ' ' + rocmSmiOpts;
try {
const res = execSync(cmd, options).toString();
return JSON.parse(res);
} catch (e) {
util.noop();
}
}
return {};
}

function rocmDevices() {
const data = rocmSmi();
if (!data || !data['card']) {
return [];
}

return data['card'].map(card => ({
name: card['Card name'],
pciBus: card['PCI Bus'],
memoryTotal: parseInt(card['VRAM Total Memory (B)']) / 1024 / 1024,
memoryUsed: parseInt(card['VRAM Used Memory (B)']) / 1024 / 1024,
temperatureGpu: parseFloat(card['Temperature (Sensor 0) (C)']),
powerDraw: parseFloat(card['Average Graphics Package Power (W)']),
clockCore: parseFloat(card['GPU Clock Frequency (MHz)']),
clockMemory: parseFloat(card['Memory Clock Frequency (MHz)']),
}));
}

function mergeControllerRocm(controller, rocm) {
if (rocm.name) { controller.name = rocm.name; }
if (rocm.pciBus) { controller.pciBus = rocm.pciBus; }
if (rocm.memoryTotal) {
controller.memoryTotal = rocm.memoryTotal;
controller.vram = rocm.memoryTotal;
controller.vramDynamic = false;
}
if (rocm.memoryUsed) { controller.memoryUsed = rocm.memoryUsed; }
if (rocm.temperatureGpu) { controller.temperatureGpu = rocm.temperatureGpu; }
if (rocm.powerDraw) { controller.powerDraw = rocm.powerDraw; }
if (rocm.clockCore) { controller.clockCore = rocm.clockCore; }
if (rocm.clockMemory) { controller.clockMemory = rocm.clockMemory; }
return controller;
}

// function starts here
return new Promise((resolve) => {
process.nextTick(() => {
Expand Down