RTX 5090 and M4 MacBook Air: Can It Game?

RTX 5090 and M4 MacBook Air: Can It Game?

RTX 5090 与 M4 MacBook Air:能玩游戏吗?

Strap a 600W GPU to your 22W CPU. What if you could strap a full desktop GPU to your MacBook Air? Turns out, you can. 将 600W 的 GPU 强行连接到 22W 的 CPU 上。如果能给 MacBook Air 外接一块完整的桌面级显卡会怎样?事实证明,这是可以做到的。

Never tell me the odds

永远别跟我谈概率

As much as I hate to admit it, step one in most of my projects now is to ask AI about it. Maybe it’ll tell me something I don’t know. Fortunately, borderline-impractical is kind of my thing. 尽管我很不想承认,但我现在大多数项目的首要步骤都是去问 AI。也许它能告诉我一些我不知道的事情。幸运的是,这种近乎不切实际的事情正是我的拿手好戏。

What’s a Thunderbolt eGPU?

什么是雷电(Thunderbolt)外置显卡?

Ok, so the plan is to plug a big PC gaming GPU, an NVIDIA RTX 5090, into my M4 MacBook Air. To do that, we plug it into a Thunderbolt dock which adapts PCIe to Thunderbolt, and we plug that into a USB-C port. 好了,计划是将一块大型 PC 游戏显卡——NVIDIA RTX 5090——插到我的 M4 MacBook Air 上。为了实现这一点,我们需要将其连接到一个将 PCIe 转换为雷电接口的扩展坞上,然后再插入 USB-C 端口。

Thunderbolt tunnels PCIe over a USB-C cable, so from the computer’s perspective a Thunderbolt device really is a PCIe device, not a USB one. You get 4 PCIe lanes at up to 40Gbps on Thunderbolt 4, with a small performance penalty for the tunneling. USB4 includes the same PCIe tunneling as an optional feature, so some non-Thunderbolt USB4 ports can do this too. You can use this to plug a GPU into a laptop with a compatible port. 雷电接口通过 USB-C 线缆传输 PCIe 信号,因此从计算机的角度来看,雷电设备实际上是一个 PCIe 设备,而不是 USB 设备。在雷电 4 接口上,你可以获得 4 条 PCIe 通道,带宽最高可达 40Gbps,不过隧道传输会带来一定的性能损耗。USB4 也将相同的 PCIe 隧道传输作为可选功能包含在内,因此一些非雷电接口的 USB4 端口也能实现这一点。你可以利用它将显卡连接到带有兼容端口的笔记本电脑上。

From the computer’s perspective, the device looks more or less like a slightly slower PCIe device, so you can usually use the same drivers you’d normally use for those devices. eGPUs work pretty much out of the box on Linux and Windows. It’s even possible to use one on a Raspberry Pi (albeit with Oculink, not Thunderbolt). 从计算机的角度来看,该设备看起来就像是一个稍慢一点的 PCIe 设备,因此你通常可以使用这些设备通用的驱动程序。外置显卡在 Linux 和 Windows 上几乎可以即插即用。甚至可以在树莓派上使用(尽管是通过 Oculink 而非雷电接口)。

The first hurdle is that macOS does not ship with drivers for NVIDIA or AMD GPUs on Apple Silicon. 第一个障碍是,macOS 在 Apple Silicon 芯片上并不提供 NVIDIA 或 AMD 显卡的驱动程序。

What about tinygrad?

tinygrad 怎么样?

tinygrad recently released their own macOS eGPU drivers. It’s a whole new AI stack with its own open source driver pipeline for NVIDIA and AMD hardware. tinygrad 最近发布了他们自己的 macOS 外置显卡驱动。这是一个全新的 AI 堆栈,拥有自己针对 NVIDIA 和 AMD 硬件的开源驱动管道。

Sadly, if your main objective is to run AI inference or play games, tinygrad probably isn’t the solution you’re looking for. This video by YouTuber Alex Ziskind shows that using an eGPU via tinygrad for inference is about 10 times slower than running native Metal inference directly on an M4 Pro without an eGPU. You can only use the tinygrad eGPU driver with the tinygrad stack, not for anything else. It also has very limited support for different AI models. 遗憾的是,如果你的主要目标是运行 AI 推理或玩游戏,tinygrad 可能并不是你想要的解决方案。YouTuber Alex Ziskind 的视频显示,通过 tinygrad 使用外置显卡进行推理的速度,比直接在 M4 Pro 上运行原生 Metal 推理要慢约 10 倍。你只能在 tinygrad 堆栈中使用 tinygrad 外置显卡驱动,不能用于其他用途。此外,它对不同 AI 模型的支持也非常有限。

Getting NVIDIA PTX code running on the GPU is one thing. Writing a full general-purpose display driver that works with arbitrary software is a significantly harder problem. So for now, what can you actually do with an eGPU and a Mac? 让 NVIDIA PTX 代码在 GPU 上运行是一回事,编写一个能与任意软件兼容的通用显示驱动程序则是一个难度大得多的问题。那么目前,在 Mac 上使用外置显卡到底能做什么呢?

The existing Linux driver

现有的 Linux 驱动

Linux can run on Apple Silicon Macs now. Regrettably, at this time, the Linux kernel does not support Thunderbolt on Apple Silicon (only internal devices and USB3). But… Linux 现在可以在 Apple Silicon Mac 上运行了。遗憾的是,目前 Linux 内核在 Apple Silicon 上并不支持雷电接口(仅支持内部设备和 USB3)。但是……

You can run Linux in a 64-bit ARM VM on a macOS host. macOS supports Thunderbolt devices. Linux supports NVIDIA GPUs. Let’s put the pieces together and pass through the GPU into the Linux VM. 你可以在 macOS 主机上通过 64 位 ARM 虚拟机运行 Linux。macOS 支持雷电设备,Linux 支持 NVIDIA 显卡。让我们把这些拼图凑在一起,将 GPU 直通(Passthrough)到 Linux 虚拟机中。

At a high level, we’re just going to put the GPU in the Linux VM. The VM is the same architecture as the Mac host (arm64), so performance should be comparable. Of course, the devil is in the details. There is no driver for NVIDIA cards on ARM64 Windows. That’s why we use Linux. 从宏观层面来看,我们只是要把 GPU 放入 Linux 虚拟机中。虚拟机的架构与 Mac 主机相同(arm64),因此性能应该是相当的。当然,细节决定成败。ARM64 版本的 Windows 没有 NVIDIA 显卡驱动,这就是我们使用 Linux 的原因。