Accelerating Reinforcement Learning through GPU Atari Emulation

Steven Dalton, Iuri Frosio, Michael GarlandarXiv 2019

TL;DR

CuLE (CUDA Learning Environment) is a GPU-native port of the Atari Learning Environment that eliminates the massive communication bottleneck between CPUs and GPUs in reinforcement learning. By emulating thousands of games simultaneously on a single GPU, it achieves throughput previously only possible with large CPU clusters, generating up to 155 million frames per hour.

What Problem Does This Paper Address?

In Deep Reinforcement Learning (DRL), the standard workflow involves a "division of labor": a CPU emulates the game environment (like Atari) to generate data, while a GPU runs the Deep Neural Network (DNN) to learn from that data.

This setup creates two major bottlenecks. First, the limited communication bandwidth between CPU and GPU makes transferring millions of video frames slow. Second, even powerful CPUs struggle to run enough parallel game instances to keep a modern GPU fully utilized. As a result, the GPU—the most expensive part of the training rig—often sits idle waiting for the CPU to finish emulating the next frame.

Methods

The authors introduce CuLE, which moves the entire emulation process onto the GPU using CUDA.

Key technical innovations include:

  • Dual-Kernel Architecture: Instead of one thread doing everything, CuLE splits the work. One CUDA kernel emulates the Atari CPU and game logic, while a second "TIA kernel" handles rendering the graphics. This separation allows for better register usage and reduces performance-killing "thread divergence."
  • Direct-to-VRAM Rendering: Frames are rendered directly into GPU memory. This completely bypasses the PCIe bus, removing the communication bottleneck.
  • Reset Caching: In standard emulators, resetting a game involves running dozens of random frames to ensure a unique starting state. On a GPU, this causes massive thread divergence as different threads execute different code paths. CuLE solves this by pre-generating and caching a library of random initial states.
  • A2C+V-trace Integration: To handle the massive influx of data from thousands of parallel environments, the authors adapted the A2C (Advantage Actor-Critic) algorithm with V-trace off-policy correction to ensure stable and fast convergence.
Figure 1: Our CUDA-based Atari emulator uses an Atari CPU kernel to emulate the functioning of the Atari CPU and advance the game state, and a second TIA ker- nel to emulate the TIA and render frames directly in GPU memory. For episode resetting we generate and store a cache of random initial states. Massive paral- lelization on GPU threads allows the parallel emulation of thousands of Atari games.

Datasets

The researchers evaluated CuLE using the standard Atari 2600 suite (via the Atari Learning Environment). They benchmarked performance across 57 different games, with deep dives into classics like Asterix, Pong, Ms. Pacman, and Assault. These games serve as the gold standard for testing an agent's ability to handle diverse visual inputs and logic.

Key Insights and Ideas

  • The Throughput vs. Latency Trade-off: The authors found that for a small number of environments (under 128), CPU emulators are actually faster because they have lower latency per thread. However, as you scale to thousands of environments, the GPU’s massive parallel throughput takes over, eventually outperforming the CPU by orders of magnitude.
  • The Cost of Divergence: A fascinating "aha moment" was quantifying how game logic affects speed. As agents in different parallel environments start making different choices, their execution paths diverge. This "thread divergence" can reduce GPU performance by up to 30% compared to the start of a level when all agents are doing roughly the same thing.
  • Effective Batching is Critical: Simply generating frames faster isn't enough. The paper shows that to actually speed up learning, you must use specific batching strategies (like increasing the number of steps per update) to leverage the high throughput without overwhelming the training process.

Key Results

  • Massive Speedup: CuLE generates up to 155M raw frames per hour on a single Titan V GPU. For comparison, the median FPS for CuLE with 4,096 environments is 3.56x higher than the peak performance of OpenAI Gym on a CPU.
  • Training Efficiency: Using a single GPU, CuLE reached a score of 18 in Pong in just 5.9 minutes. Scaling to four GPUs (System III) pushed this down to 2.4 minutes, achieving up to 187K FPS during training.
  • GPU Utilization: While traditional DRL implementations often leave the GPU underutilized (2-15% for A2C), CuLE consistently achieves 97-100% GPU utilization during training.
Figure 2: FPS and FPS per environment comparison between CuLE and OpenAI Gym, showing CuLE's superior scaling.

Limitations and Future Work

  • Memory Pressure: Storing the state and frame buffers for thousands of environments simultaneously consumes a lot of GPU DRAM. The authors noted that 16,000 environments can easily exhaust the memory of a single card. Future work could involve implementing data compression schemes.
  • Temporal "Narrowness": Because the GPU excels at running many environments for a few steps, the training data is "wide" (many samples from different states) but "narrow" in time. This can make it harder to learn from games with sparse rewards that require long-term planning.
  • Future Directions: The authors suggest that CuLE opens the door for "active sampling," where a researcher could use the massive parallel capacity to specifically seek out and train on the most important or difficult game states.

Summary updated

BibTeX
@misc{dalton2019accelerating,
  author = {Steven Dalton and Iuri Frosio and Michael Garland},
  title = {{Accelerating Reinforcement Learning through GPU Atari Emulation}},
  year = {2019},
  eprint = {1907.08467},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1907.08467},
}
Figure