← Back to all projects

CUDA LEARNING PROJECTS

Deeply Understanding CUDA

To truly understand CUDA, you need to internalize the GPU’s massively parallel execution model and how it fundamentally differs from CPU programming. This means grappling with:

Core Concept Analysis

CUDA mastery breaks down into these fundamental building blocks:

Concept What You Need to Understand
GPU Architecture SIMT execution, Streaming Multiprocessors (SMs), warps (32-thread groups), how thousands of threads execute “simultaneously”
Thread Hierarchy Grids → Blocks → Threads, why this hierarchy exists, how to map problems to it
Memory Hierarchy Global (slow), Shared (fast, per-block), Registers (fastest), Constant, Texture — and when to use each
Memory Access Patterns Coalescing (why adjacent threads should access adjacent memory), bank conflicts, cache behavior
Synchronization __syncthreads(), atomics, race conditions in massively parallel contexts
Performance Optimization Occupancy, hiding latency, avoiding warp divergence, maximizing memory bandwidth

Project 1: Interactive Mandelbrot Set Explorer

  • File: CUDA_LEARNING_PROJECTS.md
  • Programming Language: C++ (CUDA)
  • Coolness Level: Level 4: Hardcore Tech Flex
  • Business Potential: 1. The “Resume Gold”
  • Difficulty: Level 2: Intermediate
  • Knowledge Area: Parallel Computing / GPU Programming
  • Software or Tool: CUDA
  • Main Book: “Programming Massively Parallel Processors” by Hwu, Kirk & Wen

What you’ll build: A real-time fractal renderer that computes the Mandelbrot set on the GPU, displaying it in a window where you can zoom and pan interactively.

Why it teaches CUDA: The Mandelbrot set is “embarrassingly parallel” — each pixel is independent. This makes it the perfect first CUDA project because you can focus on the programming model without complex data dependencies. You’ll immediately see 100-1000x speedups over CPU code, which makes the “why” of GPU computing visceral.

Core challenges you’ll face:

  • Thread-to-pixel mapping (maps to understanding grid/block/thread indexing)
  • Warp divergence (some pixels escape quickly, others need max iterations — you’ll see real performance impact)
  • Memory transfer overhead (you’ll learn why minimizing host↔device copies matters)
  • Color mapping and visualization (getting results to screen efficiently)

Key Concepts:

  • CUDA Thread Hierarchy: “Programming Massively Parallel Processors” by Hwu, Kirk & Wen - Chapter 2
  • Kernel Launch Configuration: NVIDIA CUDA C Programming Guide - Section 2.2
  • Basic Memory Management: “CUDA by Example” by Sanders & Kandrot - Chapter 4

Difficulty: Beginner Time estimate: Weekend Prerequisites: C/C++ basics, understanding of complex numbers

Real world outcome: You’ll have a window displaying a colorful, infinitely zoomable fractal. Click to zoom in, watch the GPU recalculate millions of pixels in milliseconds. You can export high-resolution images and visually see the parallelism working.

Learning milestones:

  1. First kernel runs → You understand __global__, kernel launch syntax <<<blocks, threads>>>
  2. Interactive zooming works smoothly → You’ve grasped memory transfers and basic optimization
  3. You profile and optimize divergence → You understand warps and SIMT execution

Project 2: GPU-Accelerated Image Processing Pipeline

  • File: CUDA_LEARNING_PROJECTS.md
  • Programming Language: C++ (CUDA)
  • Coolness Level: Level 3: Genuinely Clever
  • Business Potential: 2. The “Micro-SaaS / Pro Tool”
  • Difficulty: Level 3: Advanced
  • Knowledge Area: High Performance Computing / Image Processing
  • Software or Tool: CUDA
  • Main Book: “Programming Massively Parallel Processors” by Hwu, Kirk & Wen

What you’ll build: A command-line tool that applies filters (blur, sharpen, edge detection, histogram equalization) to images, processing them entirely on the GPU.

Why it teaches CUDA: Image processing forces you to understand 2D memory layouts, shared memory tiling (for convolutions), and memory coalescing. Unlike Mandelbrot, neighboring pixels do depend on each other for filters like blur, introducing real data access patterns.

Core challenges you’ll face:

  • 2D thread block mapping to image regions (maps to understanding dim3 and 2D indexing)
  • Shared memory tiling for convolutions (the key optimization pattern — you’ll see 10x+ speedup)
  • Handling image boundaries (halo regions, padding strategies)
  • Memory coalescing (why row-major vs column-major access matters enormously)

Resources for key challenges:

  • “Programming Massively Parallel Processors” by Hwu, Kirk & Wen (Ch. 7) — The definitive explanation of convolution tiling on GPUs

Key Concepts:

  • Shared Memory: “CUDA by Example” by Sanders & Kandrot - Chapter 5
  • Memory Coalescing: “Programming Massively Parallel Processors” by Hwu, Kirk & Wen - Chapter 5
  • 2D Convolution Kernels: “Parallel Programming: Concepts and Practice” by Schmidt et al. - GPU Convolution section
  • Image Boundary Handling: NVIDIA CUDA Samples - convolutionSeparable example

Difficulty: Intermediate Time estimate: 1-2 weeks Prerequisites: Project 1 completed, basic image processing concepts

Real world outcome: Run ./imgproc blur input.jpg output.jpg and watch a 4K image get Gaussian-blurred in 5ms instead of 500ms. You can build a batch processor that handles thousands of images, or pipe it into a real-time video filter.

Learning milestones:

  1. Basic per-pixel filters work → You understand 2D kernel indexing
  2. Convolution with shared memory → You’ve internalized the most important GPU optimization pattern
  3. Pipeline processes images faster than you can load them from disk → You understand the full memory hierarchy

Project 3: Parallel Reduction — Sum a Billion Numbers

  • File: parallel_reduction_cuda.md
  • Main Programming Language: C
  • Alternative Programming Languages: C++, CUDA C++
  • Coolness Level: Level 4: Hardcore Tech Flex
  • Business Potential: Level 1: The “Resume Gold”
  • Difficulty: Level 2: Intermediate (The Developer)
  • Knowledge Area: GPU Programming, CUDA
  • Software or Tool: CUDA, NVIDIA GPU
  • Main Book: “Programming Massively Parallel Processors” by Hwu, Kirk & Wen

What you’ll build: An optimized kernel that sums a massive array (1 billion floats) faster than any CPU implementation, then extend it to other reductions (min, max, histogram).

Why it teaches CUDA: Reduction is the fundamental parallel algorithm pattern. It seems simple (just add numbers!) but forces you to understand warp-level operations, bank conflicts, and why naive parallel algorithms fail. Every serious CUDA programmer must master this.

Core challenges you’ll face:

  • Sequential addressing vs strided addressing (maps to understanding memory access efficiency)
  • Warp divergence in reduction trees (maps to understanding SIMT execution deeply)
  • Bank conflicts in shared memory (you’ll profile and see the impact)
  • Warp shuffle instructions (modern CUDA’s fastest way to communicate within a warp)
  • Multi-stage reduction (kernel can’t return one value — you need multiple passes or atomics)

Resources for key challenges:

  • Mark Harris’s “Optimizing Parallel Reduction in CUDA” (NVIDIA whitepaper) — The classic reference, walks through 7 optimization levels

Key Concepts:

  • Parallel Reduction Algorithm: “Optimizing Parallel Reduction in CUDA” by Mark Harris - NVIDIA Developer Blog
  • Warp-Level Primitives: NVIDIA CUDA C Programming Guide - Section B.15 (Warp Shuffle Functions)
  • Shared Memory Bank Conflicts: “Programming Massively Parallel Processors” by Hwu, Kirk & Wen - Chapter 5
  • Atomic Operations: “CUDA by Example” by Sanders & Kandrot - Chapter 9

Difficulty: Intermediate Time estimate: 1 week Prerequisites: Solid understanding of shared memory from Project 2

Real world outcome: A tool that can sum 1 billion floats in under 10ms on a modern GPU (vs ~1 second on CPU). You’ll have a reusable reduction template that becomes the foundation for countless algorithms. Print the result and timing to stdout — concrete proof of massive speedup.

Learning milestones:

  1. Naive reduction works but is slow → You see why parallel algorithms need careful design
  2. Shared memory reduction is 10x faster → You understand the optimization hierarchy
  3. Warp shuffle reduction matches NVIDIA’s Thrust library → You’ve mastered low-level CUDA

Project 4: Real-Time N-Body Gravitational Simulation

  • File: nbody_gravitational_simulation.md
  • Main Programming Language: C
  • Alternative Programming Languages: C++, CUDA C++
  • Coolness Level: Level 5: Pure Magic (Super Cool)
  • Business Potential: Level 1: The “Resume Gold”
  • Difficulty: Level 3: Advanced (The Engineer)
  • Knowledge Area: GPU Programming, Physics Simulation
  • Software or Tool: CUDA, OpenGL, NVIDIA GPU
  • Main Book: “GPU Gems 3” (Chapter 31)

What you’ll build: A simulation of thousands of particles attracting each other gravitationally, rendered in real-time. Think: galaxy formation, particle effects, or planetary systems.

Why it teaches CUDA: N-body is O(N²) — every particle interacts with every other. This is the canonical GPU problem because it has massive parallelism but also requires careful optimization to achieve real-time performance. You’ll learn tiling, shared memory reuse, and the all-pairs computation pattern.

Core challenges you’ll face:

  • Tiled all-pairs computation (the core algorithmic pattern for O(N²) problems on GPUs)
  • Shared memory reuse (loading particles into shared memory to reduce global memory bandwidth)
  • Numerical precision (float vs double, softening factors to avoid singularities)
  • Visualization integration (CUDA-OpenGL interop for real-time rendering)

Resources for key challenges:

  • “GPU Gems 3” Chapter 31: Fast N-Body Simulation — The authoritative reference for this algorithm

Key Concepts:

  • Tiled All-Pairs Computation: “GPU Gems 3” Chapter 31 by Lars Nyland, Mark Harris, Jan Prins
  • CUDA-OpenGL Interop: “CUDA by Example” by Sanders & Kandrot - Chapter 8
  • Occupancy Optimization: NVIDIA CUDA Occupancy Calculator and Best Practices Guide
  • Float Precision Issues: “Programming Massively Parallel Processors” by Hwu, Kirk & Wen - Chapter 6

Difficulty: Intermediate-Advanced Time estimate: 2 weeks Prerequisites: Projects 1-3 completed

Real world outcome: A mesmerizing visual simulation: thousands of glowing particles swirling, colliding, forming structures — all computed in real-time on your GPU. You can simulate 50,000+ bodies at 60fps. This is genuinely impressive to show anyone.

Learning milestones:

  1. Naive O(N²) works for 1000 bodies → You can translate algorithms to CUDA
  2. Tiled version handles 10,000 bodies in real-time → You’ve mastered shared memory tiling
  3. 50,000+ bodies at 60fps → You understand GPU architecture deeply enough to push limits

Project 5: GPU Path Tracer (Ray Tracing Renderer)

  • File: CUDA_LEARNING_PROJECTS.md
  • Programming Language: C++ (CUDA)
  • Coolness Level: Level 5: Pure Magic (Super Cool)
  • Business Potential: 1. The “Resume Gold”
  • Difficulty: Level 4: Expert
  • Knowledge Area: Computer Graphics / HPC
  • Software or Tool: CUDA / Ray Tracing
  • Main Book: “Physically Based Rendering” by Pharr, Jakob, Humphreys

What you’ll build: A physically-based renderer that traces light rays through a 3D scene, producing photorealistic images with soft shadows, reflections, and global illumination.

Why it teaches CUDA: Ray tracing has massive parallelism (each ray is independent) but also massive divergence (rays hit different materials, bounce different numbers of times). This forces you to confront the hardest parts of GPU programming: managing divergence while maintaining high occupancy.

Core challenges you’ll face:

  • Warp divergence from ray-scene intersection (rays that hit nothing vs. rays that bounce 10 times)
  • Random number generation on GPU (parallel PRNGs, cuRAND)
  • BVH traversal on GPU (stack-based algorithms on stackless hardware)
  • Memory access patterns for scene data (structure-of-arrays vs array-of-structures)

Resources for key challenges:

  • “Ray Tracing in One Weekend” by Peter Shirley — The foundation, then port it to CUDA
  • “Physically Based Rendering” by Pharr, Jakob, Humphreys — The definitive reference for understanding the math

Key Concepts:

  • Ray-Scene Intersection: “Ray Tracing in One Weekend” by Peter Shirley - Free online book
  • Handling Divergence: “Programming Massively Parallel Processors” by Hwu, Kirk & Wen - Chapter 6
  • GPU Random Number Generation: NVIDIA cuRAND Documentation
  • BVH on GPU: “Understanding the Efficiency of Ray Traversal on GPUs” - Aila & Laine (HPG 2009)

Difficulty: Advanced Time estimate: 1 month Prerequisites: Projects 1-4, basic 3D math (vectors, matrices)

Real world outcome: Render beautiful images: a glass sphere on a checkered floor, soft shadows from area lights, colorful caustics. Each image takes seconds instead of hours. You’ll have something portfolio-worthy and a deep understanding of production GPU workloads.

Learning milestones:

  1. Basic ray casting produces images → You can structure complex CUDA programs
  2. Multiple bounces with Monte Carlo sampling → You understand parallel random numbers and divergence
  3. Performance matches or beats CPU multithreaded code → You’ve mastered GPU performance optimization

Project Comparison Table

Project Difficulty Time Depth of Understanding Fun Factor
Mandelbrot Explorer Beginner Weekend ⭐⭐ (thread model basics) ⭐⭐⭐⭐⭐
Image Processing Pipeline Intermediate 1-2 weeks ⭐⭐⭐⭐ (shared memory, coalescing) ⭐⭐⭐
Parallel Reduction Intermediate 1 week ⭐⭐⭐⭐⭐ (warp-level mastery) ⭐⭐
N-Body Simulation Intermediate-Advanced 2 weeks ⭐⭐⭐⭐ (tiling, interop) ⭐⭐⭐⭐⭐
GPU Path Tracer Advanced 1 month ⭐⭐⭐⭐⭐ (divergence, complex kernels) ⭐⭐⭐⭐⭐

Recommendation

Based on learning CUDA deeply, I recommend this progression:

  1. Start with Mandelbrot (Weekend) — Get the “aha!” moment of seeing GPU parallelism work. This builds confidence and intuition.

  2. Then Parallel Reduction (1 week) — This is less flashy but critical. Every optimization technique you’ll ever use is in this project. Don’t skip it.

  3. Then Image Processing (1-2 weeks) — Shared memory tiling for 2D data is the most common real-world pattern. This cements it.

  4. Then N-Body or Path Tracer based on your interests — N-Body if you want beautiful visualizations and physics; Path Tracer if you want to understand production rendering pipelines.


Final Comprehensive Project: Build a Real-Time Neural Network Inference Engine

What you’ll build: A from-scratch inference engine that runs neural networks (like image classifiers) on the GPU, with custom CUDA kernels for matrix multiplication, convolution, activation functions, and pooling — achieving performance competitive with cuDNN.

Why this is the ultimate CUDA project: This ties everything together:

  • Matrix multiplication requires understanding memory hierarchy, tiling, and occupancy
  • Convolutions require all the image processing knowledge plus algorithmic variations (im2col, Winograd)
  • You’ll implement the entire forward pass of networks like ResNet
  • You’ll learn to profile and optimize until you match professional libraries
  • The result is genuinely useful: fast inference for any ONNX model

Core challenges you’ll face:

  • Optimized GEMM (General Matrix Multiply) — The foundation of all neural networks
  • Multiple convolution algorithms — Direct, im2col+GEMM, Winograd
  • Memory management across layers — Workspace allocation, memory pooling
  • Batching and streams — Overlapping compute and memory transfers
  • Quantization — INT8 inference for maximum performance

Key Concepts:

  • High-Performance GEMM: “Programming Massively Parallel Processors” by Hwu, Kirk & Wen - Chapter 4, 5
  • Convolution Algorithms: “Efficient Processing of Deep Neural Networks” by Sze et al. - Chapter 6
  • CUDA Streams: NVIDIA CUDA C Programming Guide - Section 3.2.8
  • Memory Optimization: “CUDA Best Practices Guide” by NVIDIA - Memory Optimizations section
  • Quantized Inference: “Integer Quantization for Deep Learning Inference” - NVIDIA whitepaper

Difficulty: Advanced Time estimate: 1-2 months Prerequisites: All previous projects, linear algebra, basic neural network understanding

Real world outcome: Point your engine at a trained model (exported to ONNX), feed it an image, and get classification results in milliseconds. Benchmark against PyTorch/TensorFlow — your hand-written CUDA should be within 2x of their heavily-optimized backends. You’ll have built something that companies pay millions to develop, and you’ll understand every byte of it.

Learning milestones:

  1. Matrix multiply achieves >50% of theoretical peak → You understand GPU architecture at a hardware level
  2. Convolutions work for standard network architectures → You can implement complex algorithms efficiently
  3. End-to-end inference matches cuDNN within 2x → You’re a production-ready CUDA developer
  4. You add INT8 quantization → You understand cutting-edge inference optimization

Final Note

CUDA is one of those skills where the gap between “can write kernels” and “can write fast kernels” is enormous. The projects above are designed to force you across that gap. Don’t just get them working — profile obsessively with nsight-compute, understand why each optimization helps, and push until you hit hardware limits. That’s when real understanding happens.