[](https://devin.ai/blog)

# Devin Gets a GPU

CognitionDecember 2, 20268 min read

Today, we’re launching GPU support for Devin’s Cloud VMs. Teams working on graphics, game development, machine learning, or scientific workloads can use NVIDIA T4s directly in Devin Cloud, with more GPU support rolling out soon.

We’ve already been floored by what early-access users have built with Devin’s new GPU powered machines. To show our excitement, we’re rolling out a program for indie gaming developers. [Apply](https://devin.ai/gaming-credits) to earn over $9,000 in Devin credits, or up to $65k if your game is growing fast.

[Watch at https://vimeo.com/1252042962/98feddf2fe](https://vimeo.com/1252042962/98feddf2fe)

## From build to playtest

Until now, Devin’s cloud VMs lacked hardware-accelerated graphics outside of Macs. Devin could build graphics-heavy applications, but testing them required bringing your own hardware through Devin Outposts.

Consider developing a game. The code compiles on a CPU, but playtesting the game with real graphics would be prohibitively slow, preventing Devin from visually debugging any changes. For example, the Minecraft mod below was developed and tested by Devin end-to-end. With just a CPU, the otter’s motion is jagged. With an NVIDIA T4 backed machine, the motion is smooth.

![](https://devin.ai/images/blog/devin-gets-a-gpu/otter-cpu-vs-t4.print.jpg)[Watch at https://devin.ai/images/blog/devin-gets-a-gpu/otter-cpu-vs-t4.mp4](https://devin.ai/images/blog/devin-gets-a-gpu/otter-cpu-vs-t4.mp4)

Devin is an autonomous software engineer: it runs what it builds, looks at the result, and fixes what it sees.

For graphics-heavy work, that loop needs more than a GPU attached to a virtual machine. Each session needs its own card, and the card has to be wiped and verified before another Devin session uses it. Devin’s desktop has to render on that card, and users should be able to view it from a browser. Finally, Devin has to know when it has access to a GPU, and when to ask for one.

## Giving VMs a physical GPU

We wanted Devin to run graphics the way a developer’s workstation does. So each GPU VM gets a real NVIDIA T4 to itself, not an emulated card or a share of one. The technique is **PCI passthrough**: the host hands the whole card to one VM, and the guest OS inside sees a T4 plugged into its own machine, running NVIDIA’s standard driver.

Passthrough relies on [VFIO](https://docs.kernel.org/driver-api/vfio.html), the Linux kernel interface that lets our virtual machine monitor (VMM) control a physical device from userspace. When a guest program submits work to the GPU, the driver places the data, like a game texture or an input tensor, in RAM. It then writes to one of the card’s control registers over memory-mapped I/O (MMIO), a range of addresses that PCIe routes to the GPU instead of RAM. The write acts like a doorbell, letting the card know that work is ready. At VM start, our VMM maps those registers directly into the guest, so the write reaches the T4 without the VMM stepping in.

A round trip to the T4

Our VMM sets up both paths when the VM starts. After that, register writes go straight to the T4, and the IOMMU limits the card to the VM’s own memory.

In the other direction, the T4 fetches the data from RAM, and later writes results back, using direct memory access (DMA). A card that reaches into RAM needs its own memory protection. At VM creation, the VMM tells the host’s IOMMU, the hardware that controls which memory a device can access, which pages belong to the VM. The IOMMU translates each DMA request to the right host page and blocks anything else.

Because the guest CPU and the GPU talk directly over PCIe, physical topology matters. On a two-socket machine, each T4 is wired to one socket; a core on the other has to cross the interconnect to reach it. We claim the card before assigning CPUs, so we can prefer CPUs on the card’s NUMA node.

CPUs and GPUs on a two-socket host

Each T4 is wired to one socket. Claiming the card first lets us prefer CPUs on its NUMA node, so they reach the card without crossing the interconnect.

The trade-off is in how a session sleeps. The card accesses guest memory directly, so that memory has to stay fixed in place, and the card’s own state is not part of a snapshot. A GPU session therefore sleeps to disk: files, dependencies, and code changes are preserved; running processes are not.

## Reusing GPUs safely

Passthrough gives one session the whole card, but only while that session runs. Cards are physical and finite, so a T4 returns to a shared pool when its session ends. The next session gets the same hardware the last one used.

When a Devin session goes to sleep, the IOMMU tears down the VM’s host RAM mappings, but the T4 still holds state: 16 GB of VRAM, on-chip shared memory and caches, and persistent settings like error-correcting code (ECC) mode. Researchers have shown that GPU memory and on-chip storage can survive across contexts and VM handoffs ([CUDA Leaks](https://arxiv.org/abs/1305.7383); [Maurice et al.](https://link.springer.com/chapter/10.1007/978-3-662-45472-5_9)). A PCIe reset alone isn’t enough.

So we operate with a zero-trust policy. We mark a card dirty the moment a VM claims it, before the guest boots. After shutdown, the host resets the card and attaches it to a minimal, network-isolated verification VM. That VM checks the card’s health and ECC state, runs a PTX kernel to zero streaming multiprocessor shared memory, allocates all usable VRAM in the ECC layout the previous session left behind, writes zeros across it, and verifies that every word reads back as zero.

If ECC was disabled or a [memory page retirement](https://docs.nvidia.com/deploy/dynamic-page-retirement/) is pending, the verifier turns ECC back on, triggers another reset, and checks again. It also re-reads retired-page counters after the sweep: any unreadable count, verification mismatch, or page retired during the sweep fails closed and pulls the card from the pool. A card that passes gets one final reset before it is marked free.

One card, from one session to the next

A card is dirty from the moment it is claimed, and is marked free only after the verification VM has zeroed it and read it back.

## Building a custom desktop stream

Giving Devin a GPU solves rendering inside the VM, but developers still need to watch, interact, and debug applications on Devin’s desktop from a browser. Devin’s virtual desktop originally ran over VNC, which sends changed rectangles of the screen over TCP. That works for terminals and applications where the screen stays mostly still, but falls apart with a game repainting the screen 60 times per second.

VNC compresses each update as still image tiles, not video. When a 3D camera pans and every pixel changes, it re-encodes and sends the full screen on every frame.

What VNC has to re-encode

Typing in a terminal

Re-encoded

Only the tiles under the new text change.

Scrolling a page

Re-encoded

The scrolled area changes, then the screen rests.

Panning a 3D camera

Re-encoded

Every tile changes on every frame.

VNC re-encodes the tiles whose pixels changed. A terminal changes a few at a time. A game changes all of them, 60 times per second.

We replaced VNC with an H.264 video stream. H.264 encodes how a frame differs from the one before it, so a panning camera costs a small fraction of a full screenshot. In the browser, WebCodecs passes the stream to the computer’s hardware video decoder. The stream grew out of the one we built for [Devin’s Mac desktop](https://devin.ai/blog/devin-gets-a-mac).

The browser still has to decide when to show each frame. Frames don’t arrive evenly: some show up late, then several arrive at once. Painting each on arrival makes motion stutter. Holding a large buffer makes clicks and keystrokes feel slow. We adapted an approach from [Moonlight](https://moonlight-stream.org/), an open-source game streaming client. Our viewer holds each frame only as long as recent network delays require, between 15 and 250 ms, and skips the rare frame that arrives too late.

Finally, the connection itself can cause stalls that we had to work around. The stream originally ran over a WebSocket, which uses TCP. TCP delivers data strictly in order, so if one packet is lost, every frame behind it waits until that packet is resent. On a busy Wi-Fi network, one lost packet can freeze the picture for a moment and then dump a burst of stale frames. To avoid this, the browser now connects to our gateway over WebTransport, which runs on QUIC over UDP. The gateway also checks each frame’s age: a frame more than 400 ms old is dropped rather than sent late, and the viewer asks for a fresh keyframe.

## Capture and Encoding on the GPU

A video stream still has to get each frame off the GPU. Our original pipeline copied every finished frame from GPU memory into system RAM, then compressed it on the CPU. Both steps compete with the game. Under heavy GPU load, the copy alone took about 24 ms per frame, holding the stream to about 41 fps.

On Linux GPU machines, the frame now stays on the card. NVIDIA’s NvFBC captures it in GPU memory, and NVENC, a video encoder built into the T4, compresses it there. Only compressed video crosses into system RAM.

Getting a frame off the GPU

BeforeCopy each frame off the card, compress on the CPU

Under heavy GPU load, the copy alone took about 24 ms per frame. Stream CPU use: more than one core.

NowCapture and compress on the card

Stream CPU use: a few percent of one core.

520×less data crossing into system RAMUncompressed frame, 12.6 MBCompressed video, 24 KB per frame

We measured both paths on Minecraft with a fixed camera path. Both held the stream near 60 fps. On the card, the slowest 1% of gaps between frames fell from about 34 ms to about 21 ms, and the stream’s CPU use fell from more than one core to a few percent of one. The trade-off is startup: the first frame takes about 0.7 seconds on the GPU path, against 0.1 on the CPU path.

## Build with GPUs today

Bringing GPUs to Devin Cloud took work from the PCIe bus up to the browser: giving each session a physical card, verifying it before reuse, replacing VNC with a video stream, and capturing and encoding that stream on the card.

Together, these pieces let Devin run and visually test graphics-heavy software in its own cloud workspace, while you watch and take control whenever you need to. Devin knows when its machine has a GPU, and can ask for one mid-session when a task calls for it.

If you’re an independent game developer, [apply](https://devin.ai/gaming-credits) to earn over $9,000 in Devin credits, or up to $65k if your game is growing fast.

We’re excited to see what you build next.

Try it today at [devin.ai](https://devin.ai/).

Table of contents

[From build to playtest](#from-build-to-playtest)[Giving VMs a physical GPU](#giving-vms-a-physical-gpu)[Reusing GPUs safely](#reusing-gpus-safely)[Building a custom desktop stream](#building-a-custom-desktop-stream)[Capture and Encoding on the GPU](#capture-and-encoding-on-the-gpu)[Build with GPUs today](#build-with-gpus-today)
