Brief: Autoencoder for CIFAR-10 with unified CPU and CUDA GPU pipelines (naive V1 and optimized V2).
- Entry & CLI: src/main.cpp — see
run_gpu_pipelineandextract_gpu. - GPU model:
GPUAutoencoder— src/gpu_autoencoder.cpp. - Kernels (naive): src/kernels.cu and header src/kernels.h.
- Optimized kernels: src/kernels_v2.cu and header src/kernels_v2.h.
- CUDA helpers: src/cuda_utils.h.
- Helper run scripts: src/run.sh, src/run_linux.sh.
- OS: Linux or Windows with WSL recommended.
- Compiler: nvcc (CUDA Toolkit) + g++ supporting C++17.
- CUDA: Toolkit 11.0+ (match driver). Tested on Compute Capability 7.x GPUs.
- Libraries: CUDA Runtime (comes with Toolkit), standard C++ STL.
- Disk: ~1GB for dataset/build artifacts.
- NVIDIA GPU with >= 8GB VRAM (e.g., RTX 2070 / RTX 30xx). For full-scale training use 12–24GB.
- 8+ CPU cores, 16GB+ RAM.
Linux example (uses nvcc to compile mixed C++/CUDA):
# filepath: README.md
nvcc main.cpp autoencoder.cpp gpu_autoencoder.cpp layers.cpp cifar10_dataset.cpp kernels.cu kernels_v2.cu \
-o autoencoder_main -O2 -std=c++17Windows (MinGW/MSVC differ) — see src/run.sh or src/run_linux.sh for ready scripts.
Usage: ./autoencoder_main <data_path> [epochs] [n_images]
Modes:
- --cpu : CPU-only training
- --gpu : GPU V1 (naive kernels)
- --gpu-v2 : GPU V2 (optimized kernels)
Examples:
# filepath: README.md
# CPU (quick test)
./autoencoder_main --cpu ../data/cifar-10-binary 5 2000
# GPU naive
./autoencoder_main --gpu ../data/cifar-10-binary 20 50000
# GPU optimized
./autoencoder_main --gpu-v2 ../data/cifar-10-binary 20 50000Internals: main dispatch in src/main.cpp calls run_gpu_pipeline which constructs GPUAutoencoder and invokes kernels in src/kernels.cu or src/kernels_v2.cu.
- Training logs:
training_log_gpu_v1.csvortraining_log_gpu_v2.csv(seeLoggerusage in GPU pipeline). - Weights:
autoencoder_weights_gpu_v1.binorautoencoder_weights_gpu_v2.bin(saved by model). - Feature dumps:
<prefix>_features.binand<prefix>_labels.binwritten byextract_gpu/ CPU extractor. - Example visualizations: files in
cpu100train20test/(PPM reconstructions).
- GPU V1: simple kernels, easier to read; lower utilization shown in profiling docs.
- GPU V2: shared-memory tiling, constant memory weight path, better occupancy (see src/kernels_v2.cu).
- If kernels fail, check CUDA errors via src/cuda_utils.h.
- Profiling outputs and optimization notes are in
profilingv1gpu.mdandprofilingv2gpu.md.
- CUDA error on launch: ensure driver + toolkit match; run
nvidia-smi. - Out-of-memory: reduce batch size / n_images or use smaller GPU model.
- Name: Nguyen Van Minh Thien
- Email: nvmthien22@clc.fitus.edu.vn