nvidia_helper.py 549 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

"""Nvidia Utility."""

import py3nvml.py3nvml as nvml


def get_device_compute_capability():
    """Get the compute capability of device.

    Return:
        cap (float): the compute capability of device, None means no device found.
    """
    nvml.nvmlInit()
    device_count = nvml.nvmlDeviceGetCount()
    if device_count == 0:
        return None

    handle = nvml.nvmlDeviceGetHandleByIndex(0)
    cap = nvml.nvmlDeviceGetCudaComputeCapability(handle)
    return cap