Skip to content
Proyectos

Cinderella-Man/how-to-enable-p2p-on-nvidia-gpus

Ver en GitHub

Acerca de

Notes on enabling GPU-to-GPU (p2p) data exchange

Productividad y automatización

Cómo se miden estas cifras

Crecimiento de estrellas medido

in 24h
+3
in 7 days
Recopilando historial
in 15 days
Recopilando historial
in 1 month
Recopilando historial

Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.

README.md

Original

How to enable P2P on NVIDIA GeForce GPUs (Ubuntu 26.04)

You have two or more GeForce cards and run one model across them. Today everything one card sends the other takes a detour through system RAM, because NVIDIA's driver switches the direct route off for GeForce cards.

This guide switches it on: GPU-to-GPU peer-to-peer (P2P) over PCIe, on Ubuntu 26.04. With P2P, one card copies straight into the other's memory instead of through system RAM. CUDA, NCCL, PyTorch and vLLM then use it with no change. It was tested and works on two RTX 3090s and on two RTX 3080s. Turing cards and pairs of two generations work too, and are marked experimental.

  • Cards of different generations that CUDA will not pair, such as a Tesla V100 beside an RTX 3090? See VRAMShare.
  • A word you do not know (P2P, NCCL, BAR1, chipset slot)? The glossary explains each in a sentence or two.
  • Let your AI set it up. Pick your cards on the setup page and paste the message it gives you into Claude Code, Codex or a similar agent on the machine. It checks your cards first, shows you the plan, and stops for the BIOS and every reboot. AI agents: clone this repository and follow SETUP-WITH-AI.md from the clone.

What you get

P2P pays off when one model is split across your cards and they exchange results after every layer: tensor split in llama.cpp, tensor parallel in vLLM, training on several cards. How much you gain depends on the slots your cards sit in more than on the cards.

llama.cpp with Qwen3.8-27B across three RTX 3090s, tokens per second for a 2048-token prompt / for generation:

Machine llama.cpp built without NCCL built with NCCL, through system RAM built with NCCL, with P2P
A consumer X570 board, one card in a chipset slot (Q8_0) 348 / 32.5 1,366 / 51.2 1,695 / 54.7
A server board, every card in a x16 CPU slot (Q4_K_M, an outside report) 795 / 41.4 860 / 67.5 2,742 / 72.3
  • Take the first step even if you never patch a driver. llama.cpp built with NCCL read prompts about 4 times faster on the consumer board, through system RAM, on NVIDIA's stock driver.
  • P2P adds the rest. On the consumer board that was 24 % on prompts and 7 % on generation. On the board where every card has a fast slot it was 3.2 times on prompts.
  • Two cards gain less than three. Two RTX 3090s on CPU lanes read prompts at 1,729 tokens/s through system RAM and at 1,818 with P2P.
  • vLLM on two RTX 3090s on CPU lanes: 26-37 % faster generation and 12 % faster prompts, through vLLM's own all-reduce, which it switches on by itself with P2P (vLLM). On other machines it ranged from slower to 32 % faster, and on a pair of two different chips with one in a chipset slot vLLM's own all-reduce reset the machine.
  • Some things do not get faster. llama.cpp's layer split gains nothing: its cards hardly exchange anything. A card in a slow slot caps every route.

The numbers for your kind of cards, and what others measured on their machines: llama.cpp, results, outside reports.

What P2P changed on the test rig

The data exchange itself, measured with NVIDIA's own tools. On the test rig one card sits in a PCIe 3.0 x4 chipset slot, which caps every route between the two cards. There P2P cut the start of a copy from 19 to 1.5 µs and raised NCCL's all-reduce from 1.9 to 2.75 GB/s, with 0 errors in 1.5 TB of test copies. Two cards on PCIe 4.0 x8 CPU lanes copied 13 GB/s. These are speeds of the data exchange, not of a whole workload: on the Turing pair vLLM generated 1 % faster. Every number: docs/results and docs/benchmarks.md.

Will it work with your cards?

Your cards P2P Follow
RTX 3080, 3080 Ti, 3090, 3090 Ti verified the procedure
RTX 20 series, GTX 16 series works, experimental the procedure, with its boxes marked Turing
An RTX 20 or GTX 16 card with an RTX 30 card works, experimental the procedure, with its boxes marked Two generations
Three or more of the cards above works the procedure; what differs: three cards
GTX 10 series, P106 and P104 mining cards, Tesla V100; Tesla P40 in an outside report verified on NVIDIA's own driver 580, with no patch pascal-and-volta.md
RTX 3050 to 3070 Ti, RTX 40 series not tested the procedure, then upstream's opt-in
RTX 50 series not tested here compatibility
A Tesla V100 or a GTX 10 card with a card of another generation not possible with P2P VRAMShare

Every setup tried so far, ours and readers', with its result: docs/compatibility.md.

Whatever the cards, the motherboard decides whether the traffic gets through and how fast. Both cards in slots wired to the CPU is best. One card in a chipset slot works, at that slot's speed. Two cards behind the same chipset, or behind the switches of a mining board, get nothing through. Check yours before you install anything: boards.md.

Ask your machine

tools/which-setup.py looks at your cards and the slots they sit in. It tells you which setup fits each pair of cards and lists the steps left. It changes nothing:

curl -sO https://raw.githubusercontent.com/Cinderella-Man/how-to-enable-p2p-on-nvidia-gpus/main/tools/which-setup.py && python3 which-setup.py

Which setup, as a picture

The same questions as a picture, for running and for training LLMs, with each setup's results at the bottom. The first YES names the fastest setup: CUDA P2P where it is possible, VRAMShare and its NCCL fork where it is not, plain NCCL through system RAM where neither works.

Running or training LLMs on two or more NVIDIA GPUs: which setup?

What it takes

  • Ubuntu 26.04 with NVIDIA's driver 615.71.09, and a second machine to work from over SSH. The procedure stops the desktop while the driver is swapped.
  • A patched kernel driver. The guide replaces NVIDIA's open kernel modules with a patched build of the same version. libcuda and nvidia-smi stay Ubuntu's own packages. Read the disclaimer; what is in the patch was checked in the security review.
  • You try before you install. The first load is a trial: nothing is installed, and a reboot returns to the stock driver. Only after the data check passes do you install it for every boot.
  • There is a way back. The last step of the procedure returns the machine to the stock driver.

Set it up

docs/procedure.md takes you from a fresh Ubuntu 26.04 install to P2P working and your programs using it, with a check after each step. Its first section is the whole procedure in nine lines. It covers RTX 30 cards, Turing cards, pairs of two generations and three or more cards: where a step differs, a box marked for those cards says so. It ends with llama.cpp built with NCCL, the biggest single step for one model across several cards: on three RTX 3090s that took prompts from about 350 to 1,370 tokens/s through system RAM, and to 1,700 with P2P.

Pascal (GTX 10, P106) and Volta (Tesla V100) cards run on NVIDIA's own driver 580, with no patch: follow pascal-and-volta.md instead. If the script or the picture names VRAMShare, see below.

OK is not proof

OK from nvidia-smi topo -p2p r means only that the driver offers P2P for that pair. It does not mean that the data arrives, nor that P2P is faster than system RAM. So far OK was wrong in eight cases, most of them without any error (the list). This guide says offered for OK, and verified only once the data was checked.

What does prove it: the data, checked, as the integrity test does (procedure step 14, ALL PASS), and a speed the link can carry. With another driver, tools/p2p_patterns.cu checks the data with only nvcc. For NCCL, PyTorch and vLLM, also look at NCCL's via line: NCCL can still go through system RAM (troubleshooting).

When P2P is not possible: VRAMShare

Use P2P whenever your pair has a route above: it works for every CUDA program. Where no route exists or none fits, the companion repository VRAMShare shares video memory between the cards instead, and that is faster than NCCL through system RAM. It is one opt-in option in nvidia-drm on NVIDIA's own driver 580, 595 or 615, with no patched driver and no patched libcuda. VRAMShare is experimental. It is not P2P: Vulkan programs use it directly, and CUDA programs through its NCCL fork, PyTorch and vLLM included.

VRAMShare is for:

  • a Tesla V100 or a Pascal card with a card of another generation. These run only on NVIDIA's closed driver 580, and CUDA refuses peer access between two architectures.
  • two generations of Turing or newer on NVIDIA's stock driver. This guide's routes for them need the patched driver, plus a patched copy of libcuda or root.
  • programs that use Vulkan rather than CUDA, such as llama.cpp's Vulkan backend.

VRAMShare does not get around the board: where the board drops peer traffic, nothing arrives either way. What VRAMShare tested: compatibility.md. How its NCCL fork compares with P2P: results.

Status

  • Verified: the whole procedure on a fresh Ubuntu 26.04.1 install, followed in order by a reader with only this repository. The integrity test passed on both RTX 30 pairs, 1.4 TiB byte-exact. The boot install brings P2P back after every reboot.
  • Experimental: Turing cards, and pairs of two generations.
  • Every setup and outside report, with its result: compatibility.md.

More documentation

How it works, in short

You do not need this to use it. NVIDIA's stock GeForce driver offers no peer access: nvidia-smi topo -p2p r says GNS, and cudaDeviceCanAccessPeer returns 0. The guide swaps NVIDIA's open kernel modules for a patched build of the same version, 615.71.09: Cinderella-Man/geforce-dynbar1-p2p. That is a fork of noon-at-cgn/geforce-dynbar1-p2p with the two fixes Ubuntu 26.04 and Linux 7.0 need, and the fixes made since (each one). The user-space driver (libcuda, nvidia-smi) stays Ubuntu's own package.

It uses Ubuntu 26.04's packaged NVIDIA driver 615 and CUDA 13.5, and was tested on two RTX 3090s, two RTX 3080s, an RTX 2060 + GTX 1650 SUPER (Turing) and an RTX 2060 + RTX 3060 (two generations). Pascal and Volta cards get P2P from NVIDIA's own driver 580.

Problems and reports

Tell us how it went on your cards and your board, working or not. Every report goes into the results, and a failure saves the next owner of the same board an evening. Include the output of python3 tools/which-setup.py.

CUDA P2P, the patched driver and the patched copy of libcuda: this repository's issues. VRAMShare, its NCCL fork and the llama.cpp copy: VRAMShare's issues.

Disclaimer

This loads an experimental, patched kernel driver. It can hang the machine or corrupt GPU memory. The upstream project has verified it only on RTX 3080 20GB pairs; other GA102 cards are "on by default, untested" there, and Turing cards are opt-in. Use at your own risk, run the integrity test on your own pair, and keep a way back to stock (p2p-fallback.sh).

Credits

Explorar proyectos relacionados

Cargando…