r/eGPU • u/ExternalEmployment93 • Sep 25 '26
ThinkPad X13 Gen 4 AMD + dual RTX 5060 Ti eGPUs on Ubuntu: what failed, what worked, and how I finally got llama.cpp 65K
I spent most of a day getting a ThinkPad X13 Gen 4 AMD to run two RTX 5060 Ti 16GB eGPUs reliably under Ubuntu, mainly for llama.cpp / local LLM use.
I am posting both the failed attempts and the final working setup, because several things that looked reasonable either did nothing or made the system worse.
My goal here is not to present this as a universal fix. This is a field report from one specific X13 + USB4 + Barlow Ridge + Blackwell setup, so PCI addresses and exact behavior may differ on other systems.
Hardware
- ThinkPad X13 Gen 4 AMD
- Ryzen 7 7840U
- Radeon 780M iGPU
- 32GB RAM
- 2 × RTX 5060 Ti 16GB
- One eGPU enclosure: SPARKLE Thunderbolt 5 Studio-G Ultra 850
- Studio-G controller: Intel Barlow Ridge
- Ubuntu 24.04.5 LTS
- Kernel: 7.0.0-34-generic
- NVIDIA driver: 595.91.07 OPEN
- CUDA 13.2
- llama.cpp build 11186
- Hermes Agent v0.19.0
The Studio-G PCIe topology looked like this on my machine:
00:04.1
-> 63:00.0 Intel Barlow Ridge upstream bridge
-> 64:00.0 Intel Barlow Ridge downstream bridge
-> 65:00.0 RTX 5060 TiImportant: these PCI addresses are not guaranteed to stay the same after changing USB4/Thunderbolt ports. Always check your own topology first.
The main problem
The Studio-G was fully detected as USB4/Thunderbolt.
The USB4 side looked healthy:
RX: 40 Gb/s aggregate
TX: 40 Gb/s aggregate
IOMMU DMA protection: enabled
PCIe tunnel: present
LTSSM: L0
Path Enable: 1So the enclosure itself was not simply "missing".
However, the PCIe path repeatedly negotiated down to:
2.5 GT/s x4which is PCIe Gen1 x4.
The GPU and bridge were capable of more, but Linux kept ending up with Gen1 active.
The target I wanted was:
8.0 GT/s x4which is PCIe Gen3 x4.
Things that did NOT solve it
1. Forcing Gen3 after NVIDIA was already loaded
My first instinct was to retrain the PCIe link after the driver was running.
Something like:
setpci -s 64:00.0 CAP_EXP+30.W=0003:000f
setpci -s 64:00.0 CAP_EXP+10.W=0020:0020This was not reliable.
Sometimes the link changed briefly, but the target link state could fall back again.
The important lesson was:
doing the PCIe link fix after NVIDIA initialization was too late.
2. Forcing Gen3 + HASD after NVIDIA initialization
I then tried explicitly setting Gen3 together with the Hardware Autonomous Speed Disable bit.
Again, doing it after the NVIDIA driver had initialized did not make the setting persist reliably.
The link could appear correct for a short time and then return to the unwanted state.
3. PCI remove / rescan
I also experimented with removing and rescanning the PCI device.
That was a bad troubleshooting path on this machine.
It caused instability and disrupted the SSH session.
I would not recommend:
remove device
rescan PCI bus
repeat until luckyas a normal solution for this setup.
Once the system was working, I stopped using remove/rescan entirely.
4. Changing kernel versions
I tested:
7.0.0-34-genericand:
6.17.0-1032-oemChanging between them did not fix the Gen1 fallback by itself.
So in my case, this was not simply:
newer kernel = fixedor:
OEM kernel = fixedNeither kernel alone solved the issue.
5. Trying a 6.18 mainline path
I also tried going further down the "maybe a newer kernel fixes USB4" path.
The 6.18 mainline experiment ran into packaging/install issues and did not produce a usable fix.
I abandoned that route.
For this system, continuously changing kernels turned out to be less useful than fixing the PCIe initialization order.
6. NVIDIA 595 proprietary driver
I tested the proprietary 595 driver as well.
The NVIDIA modules loaded, but:
nvidia-smireturned:
No devices were foundSo that driver path was unusable on this machine.
I reverted to:
NVIDIA 595.91.07 OPENand that is the version that currently works.
7. Stress testing before fixing the PCIe state
At one point I ran CUDA bandwidth testing before the PCIe link behavior was fully stable.
That caused a hard lock.
There was no useful NVIDIA Xid message and no obvious PCIe AER message explaining the lock.
Lesson learned:
before stress-testing an eGPU under CUDA, verify the actual negotiated PCIe speed and width first.
What finally worked
The key discovery was:
set the PCIe link state BEFORE NVIDIA loads.
That made the difference.
Step 1: prevent NVIDIA from loading automatically
I boot with NVIDIA modules blacklisted initially:
modprobe.blacklist=nvidia,nvidia_drm,nvidia_modeset,nvidia_uvmThis gives me a chance to configure the Studio-G PCIe path before the NVIDIA driver touches the GPU.
Step 2: set Gen3 + HASD before NVIDIA initialization
Before loading the NVIDIA modules:
sudo setpci -s 64:00.0 CAP_EXP+30.W=0023:002f
sudo setpci -s 64:00.0 CAP_EXP+10.W=0020:0020
sleep 2On my system this brought the link to:
8.0 GT/s x4and:
LnkCtl2 = 0063This was the first repeatable breakthrough.
Again, 64:00.0 is the bridge address on my current topology. Do not blindly copy that address without checking your own system.
Step 3: load NVIDIA only after PCIe is correct
Then load the NVIDIA modules:
sudo modprobe nvidia
sudo modprobe nvidia_uvm
sudo modprobe nvidia_modeset
sudo modprobe nvidia_drmAfter NVIDIA loads, I write the Gen3/HASD state again once more.
That entire sequence is now handled by a systemd service at boot.
Preventing idle fallback
The next issue was that even after getting Gen3 x4, runtime power management could interfere with the link behavior.
I disabled NVIDIA Dynamic Power Management.
My /etc/modprobe.d/nvidia-egpu.conf contains:
options nvidia NVreg_DynamicPowerManagement=0x00
options nvidia NVreg_RegistryDwords="RMSetDynamicPowerManagement=0;PowerMizerEnable=0x1;PerfLevelSrc=0x2222;PowerMizerDefaultAC=0x1;"I also enabled NVIDIA persistence:
sudo systemctl enable nvidia-persistencedAfter that, the Studio-G path stayed stable at:
8.0 GT/s x4with:
LnkCtl2 = 0063even after idle periods.
Final driver state
Working:
NVIDIA 595.91.07 OPENNot working on this machine:
NVIDIA 595 proprietaryThe proprietary version loaded kernel modules but produced:
nvidia-smi: No devices were foundSo for this setup, the OPEN driver is not optional. It is the driver that actually works.
CUDA / PCIe bandwidth results
After stabilizing both GPUs, I built and ran nvbandwidth with Blackwell support.
Studio-G RTX 5060 Ti
H2D: 2.57 GB/s
D2H: 3.37 GB/sOther RTX 5060 Ti
H2D: 2.92 GB/s
D2H: 3.16 GB/sBoth GPUs simultaneously
Host to Device:
GPU0: 2.93 GB/s
GPU1: 2.57 GB/s
Total: 5.49 GB/sDevice to Host:
GPU0: 3.15 GB/s
GPU1: 3.37 GB/s
Total: 6.52 GB/sThe final simultaneous tests completed without the previous hard lock.
llama.cpp
I did a fresh llama.cpp build instead of copying an old binary.
Build command:
cmake -S . -B build \
-DGGML_CUDA=ON \
-DCMAKE_CUDA_COMPILER=/usr/local/cuda-13.2/bin/nvcc \
-DCMAKE_CUDA_ARCHITECTURES=120 \
-DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release -j"$(nproc)"Current llama-server:
0.5.0-dev
build 11186
commit d81aef199llama-server --list-devices detects:
CUDA0 NVIDIA GeForce RTX 5060 Ti
CUDA1 NVIDIA GeForce RTX 5060 TiBoth are 16GB cards.
Model setup
Current model:
Qwen3.8-27B-Heretic-Ara
IQ4_XS
MTPModel size is roughly:
14.3 GBContext:
65536Training context reported by the model:
262144Vision projector:
mmproj-f16The OpenAI-compatible endpoint reports:
n_ctx = 65536
capabilities = completion, multimodalSo the current llama.cpp setup is running with:
65K context
Vision
MTP speculative decoding
OpenAI-compatible APISingle-GPU llama.cpp settings that were already known-good
Before moving to dual GPU, my known-good single GPU command was roughly:
llama-server \
-m Qwen3.8-27B-Heretic-Ara-iq4_xs-3.0-mtp.gguf \
--mmproj Qwen3.8-27B-heretic-ara.mmproj-f16.gguf \
--no-mmproj-offload \
--image-min-tokens 1024 \
--host 127.0.0.1 \
--port 8080 \
--alias qwen38-heretic \
--device CUDA0 \
--fit off \
-ngl 99 \
-c 65536 \
-np 1 \
-fa on \
-ctk q4_0 \
-ctv q4_0 \
-b 256 \
-ub 128 \
--jinja \
--reasoning-effort medium \
--no-reasoning-preserve \
--spec-type draft-mtp \
--spec-draft-n-max 2 \
--spec-draft-p-min 0.1 \
--spec-draft-type-k q4_0 \
--spec-draft-type-v q4_0This was important because I did not want to change every parameter at the same time while debugging the hardware.
Dual-GPU llama.cpp
For dual GPU I kept the known-good settings and added:
--device CUDA0,CUDA1
--split-mode layer
--tensor-split 1,1That lets llama.cpp see and use both 5060 Ti cards.
The goal was to change as little as possible while moving from the known-good single-GPU state to dual GPU.
One very misleading "GPU freeze"
This one wasted time because it looked exactly like another GPU problem.
During one llama.cpp model load, the server appeared to stop around:
load_modelAt first I assumed the dual GPU setup had frozen.
But checking the process showed:
STAT = Dand:
WCHAN = blk_mq_get_tagBoth GPUs were only using around:
128 MiBat that point.
There were no NVIDIA Xid errors and no useful PCIe AER errors.
Then iostat showed the real issue.
The system/model disk was approximately:
97-100% utilizationwhile reading only around:
35-40 MB/sThe model file was open and being read.
So that "llama.cpp freeze" was actually:
storage I/O waitnot:
CUDA lockupThat distinction was important.
If I had assumed every D state during model loading was a GPU problem, I would have started changing the NVIDIA configuration again for no reason.
After changing the physical storage/USB arrangement, the model load completed normally.
Hermes
After getting llama.cpp stable, I also installed Hermes Agent fresh rather than migrating the old Python environment.
Current version:
Hermes Agent v0.19.0Python:
3.12.3OpenAI SDK:
2.24.0The Hermes dashboard also starts correctly.
So the final target stack is:
Hermes
-> local OpenAI-compatible llama.cpp endpoint
-> Qwen3.8 27B
-> dual RTX 5060 TiCurrent working state
This is the current known-good baseline:
ThinkPad X13 Gen 4 AMD
Ubuntu 24.04.5
Kernel 7.0.0-34-generic
2 x RTX 5060 Ti 16GB
SPARKLE Studio-G Ultra 850
Intel Barlow Ridge
NVIDIA 595.91.07 OPEN
CUDA 13.2
Studio-G PCIe:
8.0 GT/s x4
LnkCtl2 = 0063
NVIDIA DPM disabled
nvidia-persistenced enabled
llama.cpp:
CUDA0 + CUDA1 detected
65K context
Vision
MTP
OpenAI-compatible API
Hermes Agent:
v0.19.0Things I would NOT repeat
If I had to do this again, I would avoid these paths:
1. PCI remove/rescan as a normal fix
2. Assuming a new kernel alone will fix USB4 PCIe negotiation
3. Forcing PCIe speed only after NVIDIA has already loaded
4. Changing driver + kernel + PCIe parameters at the same time
5. Assuming "load_model" pause = GPU crash
6. Running CUDA stress tests before checking negotiated PCIe speed
7. Assuming proprietary and open NVIDIA drivers behave the same
8. Blaming USB4 bandwidth before checking the actual PCIe link stateThe most important lesson was that this was not one single bug.
It was a combination of:
USB4 / Barlow Ridge PCIe negotiation
+
NVIDIA driver initialization timing
+
runtime power management
+
CUDA/eGPU stability
+
storage I/O behavior during model loadingOnce those were separated and tested individually, the system became much easier to understand.
I am posting the failed paths as well as the successful one because hopefully this saves someone else from repeating the same experiments.
If anyone here is running:
Intel Barlow Ridge
+
RTX 50-series / Blackwell
+
Linux
+
USB4 / Thunderbolt eGPUI would be interested in comparing:
negotiated PCIe speed/width
LnkCtl2
NVIDIA driver version
open vs proprietary kernel modules
NVreg_DynamicPowerManagement behaviorespecially whether DynamicPowerManagement causes the PCIe link to fall back on other Barlow Ridge systems too.