Skip to content

Commit 8811cef

Browse files
committed
refactor: Rename file for pep 8 and improve code
- added comment for the script - added else case to give helpful instructions if Cuda is not availabe!
1 parent 13385dc commit 8811cef

2 files changed

Lines changed: 20 additions & 10 deletions

File tree

TorchGPUCheck.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import torch
2+
"""
3+
This code is a simple Python script that checks if CUDA is available on the system and provides instructions on how to enable it if it's not available.
4+
"""
5+
6+
if __name__ == "__main__":
7+
print(torch.torch_version)
8+
# Check if CUDA is available
9+
if torch.cuda.is_available():
10+
print("CUDA is available!")
11+
print(f"Number of GPUs: {torch.cuda.device_count()}")
12+
print(f"Current GPU: {torch.cuda.get_device_name(torch.cuda.current_device())}")
13+
else:
14+
print("CUDA is not available.")
15+
print("To enable CUDA, follow these steps:")
16+
print("1. **Install NVIDIA Drivers**: Ensure you have the latest NVIDIA drivers installed on your system.")
17+
print("2. **Install CUDA Toolkit**: Download and install the CUDA Toolkit from the official NVIDIA website: https://developer.nvidia.com/cuda-downloads")
18+
print("3. **Verify CUDA Installation**: After installation, verify that CUDA is working correctly by running the `nvidia-smi` command in your terminal/command prompt.")
19+
print("4. **Update PyTorch**: Make sure you're using the latest version of PyTorch. You can update PyTorch using pip: `pip install --upgrade torch`")
20+
print("5. **Restart Your System**: Restart your system to ensure that the changes take effect.")

torch_gpu_check.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)