Small collection of PyTorch scripts for testing and observing GPU performance on a local CUDA-capable machine.
matrix.py, A simple benchmark that multiplies two20000x20000random matrices, once on CPU and once on GPU (cuda), timing each and printing the results for comparison.main.py, Trains aresnet50model (adapted for 100 classes) on the CIFAR100 dataset while showing a live terminal dashboard (built withcurses) of CPU usage, RAM usage, elapsed training time, and GPU utilization/memory/temperature (viapynvml/NVML). Training runs for 50 epochs with an Adam optimizer and cross-entropy loss, logging batch loss every 50 batches.
- Python 3.12
- A CUDA-capable GPU (for
main.py's GPU device selection andmatrix.py's GPU benchmark) - Dependencies (managed via
uv, seepyproject.toml):torch,torchvision,torchaudio,tensorflow,psutil,pynvml,nvidia-ml-py3
Run the CIFAR100 training with live system/GPU monitor:
uv run main.pyRun the CPU vs GPU matrix multiplication benchmark:
uv run matrix.pyNote: main.py downloads the CIFAR100 dataset into a local data/ directory on first run.