# 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](#when-p2p-is-not-possible-vramshare). - **A word you do not know** (P2P, NCCL, BAR1, chipset slot)? [The glossary](docs/glossary.md) explains each in a sentence or two. - **Let your AI set it up.** Pick your cards on [the setup page](https://cinderella-man.github.io/how-to-enable-p2p-on-nvidia-gpus/) 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](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](benchmarks/vllm/README.md#two-rtx-3090s-on-an-x570-cpu-lanes-vllms-own-all-reduce-works)). 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](docs/llama-cpp.md), [results](docs/results/README.md), [outside reports](docs/results/outside-reports.md). ### 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](docs/results/README.md) and [docs/benchmarks.md](docs/benchmarks.md). ## Will it work with your cards? | Your cards | P2P | Follow | |---|---|---| | RTX 3080, 3080 Ti, 3090, 3090 Ti | **verified** | [the procedure](docs/procedure.md) | | RTX 20 series, GTX 16 series | **works**, experimental | [the procedure](docs/procedure.md), with its boxes marked *Turing* | | An RTX 20 or GTX 16 card with an RTX 30 card | **works**, experimental | [the procedure](docs/procedure.md), with its boxes marked *Two generations* | | Three or more of the cards above | **works** | [the procedure](docs/procedure.md); what differs: [three cards](docs/three-cards.md) | | 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](docs/pascal-and-volta.md) | | RTX 3050 to 3070 Ti, RTX 40 series | not tested | [the procedure](docs/procedure.md), then upstream's [opt-in](https://github.com/Cinderella-Man/geforce-dynbar1-p2p#opt-in-for-other-chips) | | RTX 50 series | not tested here | [compatibility](docs/compatibility.md#which-path-in-detail) | | A Tesla V100 or a GTX 10 card with a card of another generation | **not possible** with P2P | [VRAMShare](#when-p2p-is-not-possible-vramshare) | Every setup tried so far, ours and readers', with its result: [docs/compatibility.md](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](docs/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: ```bash 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?](docs/assets/which-setup/which-setup.png)](docs/assets/which-setup/which-setup.png) ## 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](#disclaimer); what is in the patch was checked in the [security review](docs/security-review.md). - **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](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](docs/procedure.md#the-procedure-in-short) 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](docs/pascal-and-volta.md) instead. If the script or the picture names VRAMShare, see [below](#when-p2p-is-not-possible-vramshare). ## `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](docs/compatibility.md#ok-is-not-proof)). 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](docs/procedure.md#14-integrity-test), `ALL PASS`), and a speed the link can carry. With another driver, [`tools/p2p_patterns.cu`](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](docs/troubleshooting.md#nccl-goes-via-shm-although-cuda-offers-peer-access)). ## 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](https://github.com/Cinderella-Man/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](docs/compatibility.md#when-p2p-is-not-possible-what-vramshare-tested). How its NCCL fork compares with P2P: [results](docs/results/README.md#vramshares-nccl-fork-against-p2p). ## 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](docs/compatibility.md#status). ## More documentation - **Before you start**: [will it work with my cards](docs/compatibility.md) (every setup tried, outside reports included), [will it work on my board](docs/boards.md), [the words used here](docs/glossary.md), [the security review](docs/security-review.md). - **At the machine**: [the procedure](docs/procedure.md). Background and results for your kind of cards: [Turing](docs/turing.md), [two generations](docs/mixed-generations.md), [three or more cards](docs/three-cards.md), [Pascal and Volta](docs/pascal-and-volta.md), [llama.cpp](docs/llama-cpp.md), [Strata](docs/strata.md). - **When something goes wrong**: [troubleshooting](docs/troubleshooting.md), by what you see on the screen. - **Machines like yours**: [results](docs/results/README.md), [outside reports](docs/results/outside-reports.md), [benchmarks](docs/benchmarks.md), [vLLM](benchmarks/vllm/README.md), the [tools](tools/README.md). - **For the curious**: [how the patched driver works](docs/how-it-works.md), [what changed when](CHANGELOG.md). ## 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](https://github.com/Cinderella-Man/geforce-dynbar1-p2p). That is a fork of [noon-at-cgn/geforce-dynbar1-p2p](https://github.com/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](docs/how-it-works.md#what-the-fork-changes-compared-to-upstream)). 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](docs/results/outside-reports.md), 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](https://github.com/Cinderella-Man/how-to-enable-p2p-on-nvidia-gpus/issues). VRAMShare, its NCCL fork and the llama.cpp copy: [VRAMShare's issues](https://github.com/Cinderella-Man/vramshare/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 - [noon-at-cgn/geforce-dynbar1-p2p](https://github.com/noon-at-cgn/geforce-dynbar1-p2p): the patched driver and its scripts, which [the fork](https://github.com/Cinderella-Man/geforce-dynbar1-p2p) builds on. It in turn builds on the P2P work of tinygrad, aikitoria, Duanyll and dingiv (see its README). - [noon-at-cgn/geforce-bar1-resize](https://github.com/noon-at-cgn/geforce-bar1-resize): enlarges the Turing cards' memory window at every boot ([docs/turing.md](docs/turing.md)); this guide uses [the fork](https://github.com/Cinderella-Man/geforce-bar1-resize), which carries fixes since. - [aikitoria/open-gpu-kernel-modules](https://github.com/aikitoria/open-gpu-kernel-modules): the `libcuda` patch script that lets CUDA pair two GPU generations ([docs/mixed-generations.md](docs/mixed-generations.md)). - Christian König and the [amdgpu](https://sources.debian.org/src/linux/6.19.6-2/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c) developers: the dma-buf technique behind [vramshare](https://github.com/Cinderella-Man/vramshare), whose own credits name the llama.cpp work it builds on. - [cmp50hx-unlock](https://github.com/xrip/cmp50hx-unlock): the earlier same-chip Turing P2P report (TU102), with a different route to large windows. - [Ubsefor](https://github.com/Ubsefor/open-gpu-kernel-modules/commit/0e23c574b430c27d7b5ae394bc6ca488aff346cd): the CXL build fix for Linux 7.0. - [NVIDIA open-gpu-kernel-modules](https://github.com/NVIDIA/open-gpu-kernel-modules): the driver, dual MIT/GPLv2.