Skip to content

Commit

Permalink
print GPU information
Browse files Browse the repository at this point in the history
  • Loading branch information
AmstlerStephan committed Sep 13, 2024
1 parent b7472b6 commit 4f50808
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/workflows/umi-pipeline.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,25 @@ requiredParams = [
'input', 'reference', 'reference_fai', 'bed', 'output'
]

if(params.use_gpu){
if (params.use_gpu) {
try {
// Execute the nvidia-smi command
// Execute the nvidia-smi command to check for GPU availability
def process = "nvidia-smi".execute()
def output = new StringBuffer()
def error = new StringBuffer()

// Capture the output and error streams
process.consumeProcessOutput(output, error)
process.waitFor()

println process.exitValue() == 0 && output.toString().contains("NVIDIA-SMI")

if (process.exitValue() != 0 || !output.toString().contains("NVIDIA-SMI")) {
exit 1, "No GPU was found"
} else {
println "GPU detected: " + output.toString().split("\n")[2] // Display some GPU details
}
} catch (Exception e) {
println false
exit 1, "No GPU was found"
}

}

for (param in requiredParams) {
Expand Down

0 comments on commit 4f50808

Please sign in to comment.