-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_cuda.py
More file actions
19 lines (18 loc) · 997 Bytes
/
check_cuda.py
File metadata and controls
19 lines (18 loc) · 997 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import torch
print(f"PyTorch version: {torch.__version__}")
print(f"CUDA available: {torch.cuda.is_available()}")
if torch.cuda.is_available():
print(f"CUDA device count: {torch.cuda.device_count()}")
print(f"CUDA device name: {torch.cuda.get_device_name(0)}")
print(f"Current CUDA device: {torch.cuda.current_device()}")
else:
print("CUDA is not available. Possible reasons:")
print("1. Your system doesn't have a CUDA-compatible GPU")
print("2. CUDA drivers are not installed")
print("3. You have PyTorch installed without CUDA support")
print("\nTo fix:")
print("- If you don't have a CUDA GPU, you'll need to use CPU")
print("- If you have a CUDA GPU, install CUDA drivers from NVIDIA website")
print("- Reinstall PyTorch with CUDA support using:")
print(" pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117")
print(" (Replace cu117 with your desired CUDA version like cu118, cu121, etc.)")