Razer Core X eGPU not working in Thinkpad + Lubuntu 18.04

First, check dmesg | tail -n 200. It might show something like this:

[   74.959198] thunderbolt 0000:06:00.0: current switch config:
[   74.959201] thunderbolt 0000:06:00.0:  Switch: 8086:15da (Revision: 6, TB Version: 2)
[   74.959202] thunderbolt 0000:06:00.0:   Max Port Number: 11
[   74.959203] thunderbolt 0000:06:00.0:   Config:
[   74.959204] thunderbolt 0000:06:00.0:    Upstream Port Number: 1 Depth: 1 Route String: 0x3 Enabled: 1, PlugEventsDelay: 254ms
[   74.959205] thunderbolt 0000:06:00.0:    unknown1: 0x0 unknown4: 0x0
[   74.999560] thunderbolt 0000:06:00.0: 3: reading drom (length: 0x56)
[   75.301575] thunderbolt 0000:06:00.0: 3: uid: 0x1279cc9b0ba8400
[   75.301686] thunderbolt 0000:06:00.0:  Port 0: 8086:15d3 (Revision: 6, TB Version: 1, Type: Port (0x1))
[   75.301689] thunderbolt 0000:06:00.0:   Max hop id (in/out): 7/7
[   75.301692] thunderbolt 0000:06:00.0:   Max counters: 8
[   75.301694] thunderbolt 0000:06:00.0:   NFC Credits: 0x800000
[   75.302174] thunderbolt 0000:06:00.0:  Port 1: 8086:15d3 (Revision: 6, TB Version: 1, Type: Port (0x1))
[   75.302178] thunderbolt 0000:06:00.0:   Max hop id (in/out): 15/15
[   75.302180] thunderbolt 0000:06:00.0:   Max counters: 16
[   75.302183] thunderbolt 0000:06:00.0:   NFC Credits: 0x7800000
[   75.302681] thunderbolt 0000:06:00.0:  Port 2: 8086:15d3 (Revision: 6, TB Version: 1, Type: Port (0x1))
[   75.302683] thunderbolt 0000:06:00.0:   Max hop id (in/out): 15/15
[   75.302685] thunderbolt 0000:06:00.0:   Max counters: 16
[   75.302687] thunderbolt 0000:06:00.0:   NFC Credits: 0x0
[   75.302689] thunderbolt 0000:06:00.0: 3:3: disabled by eeprom
[   75.302691] thunderbolt 0000:06:00.0: 3:4: disabled by eeprom
[   75.302692] thunderbolt 0000:06:00.0: 3:5: disabled by eeprom
[   75.302806] thunderbolt 0000:06:00.0:  Port 6: 8086:15d3 (Revision: 6, TB Version: 1, Type: PCIe (0x100102))
[   75.302808] thunderbolt 0000:06:00.0:   Max hop id (in/out): 8/8
[   75.302809] thunderbolt 0000:06:00.0:   Max counters: 2
[   75.302811] thunderbolt 0000:06:00.0:   NFC Credits: 0x800000
[   75.302960] thunderbolt 0000:06:00.0:  Port 7: 8086:15d3 (Revision: 6, TB Version: 1, Type: PCIe (0x100101))
[   75.302962] thunderbolt 0000:06:00.0:   Max hop id (in/out): 8/8
[   75.302964] thunderbolt 0000:06:00.0:   Max counters: 2
[   75.302966] thunderbolt 0000:06:00.0:   NFC Credits: 0x800000
[   75.302967] thunderbolt 0000:06:00.0: 3:8: disabled by eeprom
[   75.302969] thunderbolt 0000:06:00.0: 3:9: disabled by eeprom
[   75.302971] thunderbolt 0000:06:00.0: 3:a: disabled by eeprom
[   75.302973] thunderbolt 0000:06:00.0: 3:b: disabled by eeprom

That suggests a permissions/security issue.

Let's install Thunderbolt Admin Tools so we can fix it:

sudo apt install thunderbolt-tools

Now, let's check to see if Thunderbolt sees the dock:

root@mymachine:~# tbtadm devices
0-4 Razer Core X  non-authorized  not in ACL

It does!

Now, let's authorize the dock:

tbtadm approve 0-4

This shows:

Authorizing "/sys/bus/thunderbolt/devices/0-4"
Already in ACL
system:5 Input/output error

Unplugging and replugging the dock and looking at dmesg again shows:

[11187.232181] thunderbolt 0000:06:00.0: PCIe tunnel creation failed

So we look at Thunderbolt again:

root@mymachine:~# tbtadm devices
0-4 Razer Core X  non-authorized  in ACL

And, indeed, we can see that the dock is connected:

root@mymachine:~# tbtadm acl
0XXXXXb0-XXXX-XXXX-ffff-ffffffffffff  Razer Core X  connected

Let's try to authorize things manually:

root@mymachine:~# echo '1' > /sys/bus/thunderbolt/devices/0-4/authorized 
-bash: echo: write error: Input/output error

At this point, I suspected the BIOS might be the issue. So, restart, pull up the BIOS setup. It's in "User Authorization", but let's use the nuclear "No Security" option (probably good to figure out how to lock things down again later): BIOS Thunderbolt Setup

At this point, boot the machine again.

Before plugging in the GPU, ensure you have the Nvidia drivers loaded:

sudo modprobe nvidia-uvm

And try to find the GPU:

nvidia-smi

Success!

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 418.87.00    Driver Version: 418.87.00    CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce RTX 208...  Off  | 00000000:3D:00.0 Off |                  N/A |
| 15%   36C    P0     1W / 250W |      0MiB / 10989MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

According to this document the BIOS settings mean:

  • No Security: Allow Thunderbolt devices to be connected automatically.
  • User Authorization: Allow Thunderbolt devices to be connected after user authorization.
  • Secure Connect: Allow Thunderbolt devices to be connected with a saved key that has been approved by the user.
  • Display Port and USB: Allow only Display outputs and USB devices to be connected. Thunderbolt devices are not allowed to be connected