File size: 1,797 Bytes
01d5a5d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
45
46
47
48
49
50
51
52
#!/usr/bin/env python3

import torch
import subprocess
import sys
import os

print("=== PyTorch CUDA Version Information ===")
print(f"PyTorch version: {torch.__version__}")

if torch.cuda.is_available():
    print(f"CUDA available: Yes")
    print(f"CUDA version used by PyTorch: {torch.version.cuda}")
    print(f"cuDNN version: {torch.backends.cudnn.version() if torch.backends.cudnn.is_available() else 'Not available'}")
    print(f"GPU device name: {torch.cuda.get_device_name(0)}")
    
    # Try to check system CUDA version
    try:
        nvcc_output = subprocess.check_output(["nvcc", "--version"]).decode("utf-8")
        print("\nSystem NVCC version:")
        print(nvcc_output)
    except:
        print("\nNVCC not found in PATH")
        
    # Check CUDA libraries
    try:
        print("\nChecking required CUDA libraries:")
        for lib in ["libcudart.so", "libcublas.so", "libcublasLt.so"]:
            print(f"\nSearching for {lib}:")
            find_result = subprocess.run(f"find /usr -name '{lib}*'", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            if find_result.returncode == 0 and find_result.stdout:
                print(find_result.stdout.decode("utf-8"))
            else:
                print(f"No {lib} found in /usr")
    except Exception as e:
        print(f"Error checking libraries: {e}")
        
    # Check LD_LIBRARY_PATH 
    print("\nLD_LIBRARY_PATH:")
    print(os.environ.get("LD_LIBRARY_PATH", "Not set"))
    
else:
    print("CUDA not available")
    
# Check system CUDA installation
print("\n=== System CUDA Information ===")
try:
    nvidia_smi = subprocess.check_output(["nvidia-smi"]).decode("utf-8")
    print("NVIDIA-SMI output:")
    print(nvidia_smi)
except:
    print("nvidia-smi not found or not working")