Skip to content

Commit

Permalink
fix frontend crash when gpu data is missing
Browse files Browse the repository at this point in the history
also remove hardcoded case for 2 gpus
  • Loading branch information
conradtchan committed Sep 18, 2024
1 parent 3fe67d7 commit c185973
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions frontend/src/usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,19 @@ export function getNodeUsage(jid, job, node, host) {
}
}

// If thif is a GPU job
// If this is a GPU job
let gpuNumbers = [];
if (job.nGpus > 0) {
if (job.nGpus > 0 && node.gpus) {
// Zero if unknown
usage.gpu.total = 0;

// TODO: currently hardcoded to 2,
// but can make this general from the API
const nGpuMax = 2;

// If the GPU mapping is known
if (Object.prototype.hasOwnProperty.call(job.gpuLayout, host)) {
if (job.gpuLayout[host].length > 0) {
gpuNumbers = job.gpuLayout[host];
}
// If both GPUs are used in a 2 GPU job, then mapping doesn't matter
} else if (job.nGpus === nGpuMax) {
for (let j = 0; j < nGpuMax; j += 1) {
gpuNumbers.push(j);
}
}

for (let j = 0; j < gpuNumbers.length; j += 1) {
const iGpu = gpuNumbers[j];
usage.gpu.total += node.gpus["gpu".concat(iGpu.toString())];
Expand Down

0 comments on commit c185973

Please sign in to comment.