Skip to content

other

Functions:

get_nvidia_version

get_nvidia_version() -> tuple[int, int] | None

Check if nvidia drivers are installed and if available return the version.

Source code in vstools/utils/other.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
def get_nvidia_version() -> tuple[int, int] | None:
    """
    Check if nvidia drivers are installed and if available return the version.
    """

    try:
        smi = run(["nvidia-smi", "-q"], capture_output=True)
    except FileNotFoundError:
        pass
    else:
        if not smi.returncode:
            return _str_to_ver(smi.stdout.splitlines()[5].decode().split(":")[-1])

    return None

is_gpu_available

is_gpu_available() -> bool

Check if any GPU is available.

Source code in vstools/utils/other.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
def is_gpu_available() -> bool:
    """
    Check if any GPU is available.
    """

    try:
        smi = run(["nvidia-smi"], capture_output=True, text=True)
    except FileNotFoundError:
        pass
    else:
        if smi.returncode == 0:
            return True

    try:
        rocm_smi = run(["rocm-smi"], capture_output=True, text=True)
    except FileNotFoundError:
        pass
    else:
        if rocm_smi.returncode == 0:
            return True

    return False