Skip to content

Instantly share code, notes, and snippets.

@ovuruska
Created September 8, 2024 06:43
Show Gist options
  • Save ovuruska/421dd85b49b3bf86a0ee51170b8701c8 to your computer and use it in GitHub Desktop.
Save ovuruska/421dd85b49b3bf86a0ee51170b8701c8 to your computer and use it in GitHub Desktop.
Get System Details
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