forked from JuliaGPU/CUDA.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nvml.jl
44 lines (35 loc) · 1.17 KB
/
nvml.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using CUDA.NVML
macro maybe_unsupported(ex)
quote
try
$(esc(ex))
catch err
(isa(err, NVMLError) && err.code == NVML.ERROR_NOT_SUPPORTED) || rethrow()
end
end
end
@testset "system" begin
@test NVML.version() isa VersionNumber
@test NVML.driver_version() isa VersionNumber
@test NVML.cuda_driver_version() == CUDA.version()
end
@testset "devices" begin
dev = NVML.Device(0)
@test dev == first(NVML.devices())
cuda_dev = CuDevice(0)
nvml_dev = NVML.Device(uuid(cuda_dev))
@test NVML.uuid(nvml_dev) == uuid(cuda_dev)
NVML.brand(nvml_dev)
@test NVML.name(nvml_dev) == name(cuda_dev)
@maybe_unsupported NVML.serial(nvml_dev)
@maybe_unsupported NVML.power_usage(nvml_dev)
@maybe_unsupported NVML.energy_consumption(nvml_dev)
NVML.memory_info(nvml_dev)
@maybe_unsupported NVML.utilization_rates(nvml_dev)
NVML.compute_mode(nvml_dev)
@test NVML.compute_capability(nvml_dev) == capability(cuda_dev)
context()
# FIXME: https://github.com/NVIDIA/gpu-monitoring-tools/issues/63
#@test getpid() in keys(NVML.compute_processes(dev))
NVML.compute_processes(dev)
end