Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active December 15, 2025 17:29
Show Gist options
  • Select an option

  • Save dacr/b6cb0b6f61e507dac8bcf34231308d82 to your computer and use it in GitHub Desktop.

Select an option

Save dacr/b6cb0b6f61e507dac8bcf34231308d82 to your computer and use it in GitHub Desktop.
get some gpu information / published by https://github.com/dacr/code-examples-manager #2823b304-e6a7-47fb-80b2-4ca33fb3cc3d/9623f27038c5586d29555e0980f659fd90c55352
// summary : get some gpu information
// keywords : djl, machine-learning, gpu, @testable
// publish : gist
// authors : David Crosson
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2)
// id : 2823b304-e6a7-47fb-80b2-4ca33fb3cc3d
// created-on : 2024-02-18T11:58:44+01:00
// managed-by : https://github.com/dacr/code-examples-manager
// run-with : scala-cli $file
// ---------------------
//> using scala "3.7.2"
//> using dep "org.slf4j:slf4j-api:2.0.17"
//> using dep "org.slf4j:slf4j-simple:2.0.17"
//> using dep "ai.djl:api:0.33.0"
//> using dep "ai.djl:basicdataset:0.33.0"
//> using dep "ai.djl:model-zoo:0.33.0"
//> using dep "ai.djl.pytorch:pytorch-engine:0.33.0"
//> using dep "ai.djl.pytorch:pytorch-model-zoo:0.33.0"
import ai.djl.Device
import ai.djl.util.cuda.CudaUtils
// ---------------------
val device = Device.gpu()
println(
s"""
cuda version : ${CudaUtils.getCudaVersion}
cuda version string : ${CudaUtils.getCudaVersionString}
gpu count : ${CudaUtils.getGpuCount}
gpu memory : ${CudaUtils.getGpuMemory(device)}
"""
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment