Created
September 8, 2024 06:43
-
-
Save ovuruska/421dd85b49b3bf86a0ee51170b8701c8 to your computer and use it in GitHub Desktop.
Get System Details
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import platform | |
import torch | |
def get_gpu_info(): | |
if torch.cuda.is_available(): | |
return torch.cuda.get_device_name(0) | |
else: | |
return "No CUDA-capable GPU found" | |
def get_cuda_version(): | |
if torch.cuda.is_available(): | |
return torch.version.cuda | |
else: | |
return "CUDA not available" | |
def get_cpu_info(): | |
try: | |
with open('/proc/cpuinfo', 'r') as f: | |
for line in f: | |
if line.strip().startswith('model name'): | |
return line.strip().split(':')[1].strip() | |
except: | |
return "CPU information not available" | |
def get_ram(): | |
try: | |
total_memory = os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') | |
return f"{total_memory / (1024**3):.2f} GB" | |
except: | |
return "RAM information not available" | |
gpu_info = get_gpu_info() | |
cpu_info = get_cpu_info() | |
ram_info = get_ram() | |
python_version = platform.python_version() | |
pytorch_version = torch.__version__ | |
cuda_version = get_cuda_version() | |
print(f"GPU: {gpu_info}") | |
print(f"CPU: {cpu_info}") | |
print(f"RAM: {ram_info}") | |
print(f"Python Version: {python_version}") | |
print(f"PyTorch Version: {pytorch_version}") | |
print(f"CUDA Version: {cuda_version}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment