Skip to content

nguyenvmthien/ParallelProgramming-FinalProject

Repository files navigation

PP Final — Autoencoder (CPU / GPU V1 / GPU V2)

Brief: Autoencoder for CIFAR-10 with unified CPU and CUDA GPU pipelines (naive V1 and optimized V2).

Quick links

Requirements

  • 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.

Hardware (recommended)

  • NVIDIA GPU with >= 8GB VRAM (e.g., RTX 2070 / RTX 30xx). For full-scale training use 12–24GB.
  • 8+ CPU cores, 16GB+ RAM.

Build / Compile

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++17

Windows (MinGW/MSVC differ) — see src/run.sh or src/run_linux.sh for ready scripts.

Run / Usage

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 50000

Internals: 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.

Outputs

  • Training logs: training_log_gpu_v1.csv or training_log_gpu_v2.csv (see Logger usage in GPU pipeline).
  • Weights: autoencoder_weights_gpu_v1.bin or autoencoder_weights_gpu_v2.bin (saved by model).
  • Feature dumps: <prefix>_features.bin and <prefix>_labels.bin written by extract_gpu / CPU extractor.
  • Example visualizations: files in cpu100train20test/ (PPM reconstructions).

Expected behavior / notes

  • 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.md and profilingv2gpu.md.

Troubleshooting

  • CUDA error on launch: ensure driver + toolkit match; run nvidia-smi.
  • Out-of-memory: reduce batch size / n_images or use smaller GPU model.

Author

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors