Caffe con Troll: Shallow Ideas to Speed Up Deep Learning

Firas Abuzaid, Stefan Hadjis, Ce Zhang, Christopher Ré

Abstract

We present Caffe con Troll (CcT), a fully compatible end-to-end version of the popular framework Caffe with rebuilt internals. We built CcT to examine the performance characteristics of training and deploying general-purpose convolutional neural networks across different hardware architectures. We find that, by employing standard batching optimizations for CPU training, we achieve a 4.5x throughput improvement over Caffe on popular networks like CaffeNet. Moreover, with these improvements, the end-to-end training time for CNNs is directly proportional to the FLOPS delivered by the CPU, which enables us to efficiently train hybrid CPU-GPU systems for CNNs.

Introduction

Deep learning is notoriously compute-bound, leading to a heavy industry reliance on GPUs. However, GPUs face limitations such as slow PCI-e interconnect bottlenecks and, historically, limited availability across all major cloud providers. Meanwhile, modern CPUs have gained significant SIMD parallelism that remains underutilized by standard deep learning frameworks.

The default implementation of Caffe, for instance, often processed images through convolutional layers with a batch size of one, leading to poor cache utilization and memory-bandwidth bottlenecks on CPUs. Furthermore, existing frameworks typically forced a binary choice: training on either the CPU or the GPU. Caffe con Troll (CcT) was developed to bridge this gap, leveraging the idle compute power of CPUs even during GPU-based training.

Methodology

CcT is a fork of Caffe that optimizes convolutional layers, which typically account for 70-90% of total execution time. The system introduces two primary optimizations:

Batching and Lowering

Instead of sequential processing, CcT batches images during the convolution phase. This creates larger matrices that allow Basic Linear Algebra Subprograms (BLAS) libraries to better utilize L2/L3 caches and parallelize across CPU cores.

The process of convolution via lowering, matrix multiplication, and lifting.

As shown in Figure 1, convolutions are computed via "lowering"—reshaping 3D image and kernel tensors into 2D matrices for standard matrix multiplication (GEMM), then "lifting" the result back to 3D. CcT analyzes different lowering strategies to find the optimal balance between memory footprint and compute time based on the ratio of input to output channels.

Hybrid CPU-GPU Scheduling

CcT enables data parallelism within a single layer across both the CPU and GPU simultaneously. It utilizes a static scheduling heuristic, routing input batch fractions to each device proportional to their theoretical peak FLOPS. This simple approach achieves performance within 5% of optimal dynamic scheduling.

Key Results

Evaluations using the ImageNet dataset and the CaffeNet (AlexNet) architecture demonstrate significant performance gains.

Comparison of CcT and Caffe performance across CPU, GPU, and hybrid configurations.

As detailed in Figure 5, CcT achieved a 4.5x end-to-end throughput improvement over standard Caffe on an AWS EC2 CPU instance (c4.4xlarge). In hybrid configurations, utilizing the CPU alongside the GPU resulted in a >15% end-to-end speedup over the GPU alone. Furthermore, the system demonstrated strong scalability, achieving a 3.12x speedup when scaling to 4 GPUs.

From a financial perspective, running CcT on CPU-only instances was only 2.6x more expensive per iteration than GPU instances, making CPU-based training a viable fallback in environments where GPUs are unavailable.

Conclusion and Future Work

The performance gap between CPUs and GPUs in deep learning is partly a software artifact. By removing bottlenecks like batch-size-1 convolutions, end-to-end training time becomes directly proportional to hardware FLOPS. While CcT currently focuses on data parallelism, future work aims to support model parallelism for large fully-connected layers and incorporate Fast Fourier Transform (FFT) based convolution optimizations.

Summary updated

Abstract

We present Caffe con Troll (CcT), a fully compatible end-to-end version of the popular framework Caffe with rebuilt internals. We built CcT to examine the performance characteristics of training and deploying general-purpose convolutional neural networks across different hardware architectures. We find that, by employing standard batching optimizations for CPU training, we achieve a 4.5x throughput improvement over Caffe on popular networks like CaffeNet. Moreover, with these improvements, the end-to-end training time for CNNs is directly proportional to the FLOPS delivered by the CPU, which enables us to efficiently train hybrid CPU-GPU systems for CNNs.
BibTeX
@inproceedings{abuzaid2015caffe,
  author = {Firas Abuzaid and Stefan Hadjis and Ce Zhang and Christopher Ré},
  title = {{Caffe con Troll: Shallow Ideas to Speed Up Deep Learning}},
  booktitle = {DanaC@SIGMOD},
  year = {2015},
  url = {https://openreview.net/forum?id=04nkmRsrygA},
}
Figure