summaryrefslogtreecommitdiff
path: root/.tmp_gpu_check2.py
blob: 75551553a375444b3705a5372b0aef63dc774363 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import os
print("ENV CUDA_VISIBLE_DEVICES:", os.environ.get("CUDA_VISIBLE_DEVICES"))
try:
    import torch
    print("torch:", torch.__version__, "cuda:", getattr(torch.version, "cuda", None))
    print("built_with_cuda:", torch.backends.cuda.is_built())
    print("device_count:", torch.cuda.device_count())
    print("is_available:", torch.cuda.is_available())
    if torch.cuda.device_count() > 0:
        for i in range(torch.cuda.device_count()):
            try:
                print(f"[{i}]", torch.cuda.get_device_name(i))
            except Exception as e:
                print(f"[{i}] name error:", e)
except Exception as e:
    print("torch error:", repr(e))