Skip to content

Instantly share code, notes, and snippets.

@leihanchen
leihanchen / model_investigation.py
Created October 27, 2025 23:43
Print a pth model structure and info using PyTorch
import argparse
import os
import torch
# ---Configuration---
# Default path can still be overridden via --file at runtime.
FILE_PATH = "model.pth"
@leihanchen
leihanchen / cuda_check.py
Last active October 27, 2025 23:30
CUDA device detection using Pytorch
import torch
# Check if CUDA is available
if torch.cuda.is_available():
# Get the version of CUDA that PyTorch is using
cuda_version = torch.version.cuda
print(f"PyTorch CUDA version: {cuda_version}")
# Get the number of available CUDA devices
num_devices = torch.cuda.device_count()