GPU Computing · Jan 2026 - Feb 2026
Custom CUDA Library for CNN Pre-Processing
An open-source CUDA library that accelerates CNN preprocessing - matrix multiplication and image convolution - with drop-in Python bindings so existing NumPy pipelines run on the GPU without a rewrite.
Why this exists
Most training pipelines preprocess on the CPU - normalization, augmentations, convolutions - then ship tensors to the GPU. That leaves expensive hardware idle while O(n³) matrix work and pixel loops run on a single thread pool. This project ships a reusable library instead of a one-off script: optimized CUDA kernels packaged as Python-callable shared objects.
Repository
The full implementation, notebooks, and reproduction steps live in a public repo:
github.com/ShamikOfficial/CUDA-Accelerated-Python-Library →
- Matrix module - CPU baseline, naive CUDA, shared-memory tiled CUDA (16×16 tiles), and cuBLAS reference, benchmarked for N = 64 to 2048.
- Convolution module - edge detection, sharpen, and Gaussian blur at 3×3, 5×5, and 7×7, with one GPU thread per output pixel.
- Python bindings -
libmatrix.soandlibconvo.soloaded via ctypes over NumPy float32 arrays.
Architecture
- Tiled shared memory: each block loads a 16×16 tile of A and B into on-chip memory once, eliminating the redundant global reads that bottleneck the naive kernel.
- CUDA events timing: warm-up launches plus event-based measurement on Tesla T4 (
-arch=sm_75) for reproducible benchmarks. - Zero-padded convolution: boundary-safe filters with configurable modes (
edge_n3,sharpen_n7, etc.) and output clipped to 0-255.
Results
- GPU outperforms CPU at every matrix size tested; the gap widens sharply as N grows.
- Tiling delivers the largest gains at medium-to-large sizes; overhead dominates at very small N.
- Custom tiled kernel is competitive with cuBLAS on small matrices; cuBLAS pulls ahead at the heaviest workloads.
- Convolution speedups scale with image area - GPU parallelism pays off once transfer cost is amortized.
Impact
- 115× speedup over CPU at N=1024 and 14× faster PyTorch preprocessing.
- Drop-in GPU acceleration for standard Python ML workflows - no pipeline rewrite required.
Tech
Technical report
Full technical report from the Clean source: Module 1 matrix multiplication (CPU, naive CUDA, tiled shared memory, cuBLAS), analysis Q&A, benchmark charts, Python libmatrix.so bindings, Module 2 image convolution (grayscale, edge/sharpen/Gaussian filters with result images), CUDA port, and libconvo.so Python library.