Skip to content

Commit

Permalink
Use process build for GPU command (#2632)
Browse files Browse the repository at this point in the history
* Add GPU ID validation

* update

* updates

* Update WorkerThread.java
  • Loading branch information
msaroufim committed Sep 29, 2023
1 parent bfb3d42 commit 7b1c359
Showing 1 changed file with 10 additions and 6 deletions.
Expand Up @@ -120,12 +120,16 @@ public String getGpuUsage() {
try {
// TODO : add a generic code to capture gpu details for different devices instead of
// just NVIDIA
process =
Runtime.getRuntime()
.exec(
"nvidia-smi -i "
+ gpuId
+ " --query-gpu=utilization.gpu,utilization.memory,memory.used --format=csv");
ProcessBuilder pb =
new ProcessBuilder(
"nvidia-smi",
"-i",
String.valueOf(gpuId),
"--query-gpu=utilization.gpu,utilization.memory,memory.used",
"--format=csv");

// Start the process
process = pb.start();
process.waitFor();
int exitCode = process.exitValue();
if (exitCode != 0) {
Expand Down

0 comments on commit 7b1c359

Please sign in to comment.