Generative AI Using Linuxulator and eGPU on FreeBSD A FreeBSD user documented running generative AI workloads on FreeBSD by combining the operating system's Linux Binary Compatibility layer (Linuxulator) with an external NVIDIA eGPU, after native Python compilation errors and missing dependencies blocked a direct install. The setup installs FreeBSD NVIDIA drivers first, then adds matching NVIDIA Linux libraries into a Rocky Linux 9.7 userland at /compat/linux, where the author compiled and installed Python 3.10 and pulled dependencies via dnf packages from a temporary RL9 installation. The author framed the result as working "given an organized small amount of command line spells. Generative AI using Linuxulator and eGPU on FreeBSD 3369 words, 16 minutes Not so long ago, I experimented on so-called Generative AI using an external eGPU and Slackware Linux https://www.tumfatig.net/2024/generative-ai-using-egpu-on-slackware-linux/ . Because I’m a BSD fanboy, I started looking at doing the same on FreeBSD. But I faced a lot of missing dependencies issues and Python compilation errors. As a non fluent Python person, I couldn’t solve all the errors I encountered and decided to see if the FreeBSD Linux Binary Compatibility https://docs.freebsd.org/en/books/handbook/linuxemu/ feature would be able to achieve the goal; after all, there are people using it to watch DRM stuff from the Clouds. Spoiler alert : it does work given an organized small amount of command line spells. AI opinion Feel free to jump to the next section if you don’t care about AI opinions ;- These days, AI is sold and forced everywhere. I am not the last to yell at Mozilla for pushing some shit into Firefox. I’m also pretty sure vibe coding https://en.wikipedia.org/wiki/Vibe coding is a bad idea. I have tested things like ChatGPT for a few things. Asking for help to debug error messages lead nowhere but to Stack Overflow and Unix & Linux Stack Exchange. Asking for pre-made code offered mostly non-working stuff but I must admit it gave me ideas by identifying features from software I didn’t know. Asking for product comparison was more or less an extract of Tom’s Hardware or Les Numériques. Asking for differences between technology A and B and better use cases felt approximate enough that I usually ended up sending words to SearXNG in order to get more informations. I also tested the Bing Image Generator; although I’m aware of the global harvesting of copyrighted data this implied. My opinion was that it was not as good as it was sold. It was about the same quality as child-me collecting free cliparts, colouring in Paint and organising in Designer… All in all, my take is that AI is not Artificial Intelligence. It’s not intelligence at all, yet. At best, it is Algorithm Induce. At worse, it is Aleatory Inference. And most of all, Machine Learning, Neural Networks and LLMs are not the same thing. I hate the Big Tech’s AI because they are thieves and liars. But I am still interested in the local software that can provide features other software don’t yet. And this is why I keep an eye on running stuff like Python Torch. I have not yet looked at LLaMA. To paraphrase some Monday meme, my take is that You don’t hate AI. You hate LLMs in the context of capitalism and patriarchy. Overall software overview There are quite a few bricks to assemble here. There may be smarter way but I have not found any all-in-one documentation. So I settled on choices based on my lack of knowledge. The OS is installed without particular requirements. I install software using binary packages as much as possible. The FreeBSD NVIDIA drivers are installed and configured first. When everything seems to be working, the Linux Binary Compatibility part can begin. There is a need to have NVIDIA Linux libraries available. Because it has to be the same version as the FreeBSD ones, I installed the dedicated package. From there, you get a /compat/linux directory with a fairly basic Rocky Linux 9.7 installation. It is bare enough to not ship with a package manager. As I have to install more software in the Linux userland, I’m using a temporary RL9 installation to grab dnf packages that will be installed in the /compat/linux directory. This allows installing some more software in an easy way - dealing with binary packages and dependencies. There is a dnf package in FreeBSD ports but I never understood how to use it with /compat/linux . Using the dnf package manager, I installed various required tools and libraries for later usage. I grabbed, compiled and installed Python 3.10 into the /compat/linux directory. Mostly because this version seem to be the one all the tools I tested need. The I installed a few additional NVIDIA / CUDA tools and librairies inside /compat/linux . There is also a specific NVIDIA Unified Memory UVM program to install in order to use the NVIDIA GPU from with Linuxulator. Finally, a bunch of Python virtual environments can be populated to use PyTorch based-software. Hardware, BIOS, OS As described in details here https://www.tumfatig.net/2024/generative-ai-using-egpu-on-slackware-linux/ , I am using an NVIDIA RTX 4060 Ti, connected via a Thunderbolt eGPU docking station to a Topton GM1 head-less machine. The BIOS is configured with “No Security” so that the hardware is recognised automatically. I have done all my trial & errors on a ThinkPad T480s running FreeBSD 14.3. It went the same way as my final configuration using FreeBSD 14.4 on the Topton. I didn’t go for 15.0 as I already had two bad experience with it on different projects and I see a lot of people on the Fediverse having issues with 15 too. Install and update FreeBSD 14.4/amd64. freebsd-update fetch freebsd-update install Everything else will be done remotely using SSH. FreeBSD NVIDIA drivers For some reasons, FreeBSD doesn’t support eGPU hotplug on the ThinkPad. The NVIDIA card has to be powered on and connected to the computer when it boots FreeBSD. This may change in the future. The Handbook explains how to install the NVIDIA FreeBSD drivers https://docs.freebsd.org/en/books/handbook/x11/ x-configuration-nvidia . pkg install -y nvidia-drm-kmod pkg info | grep nvidia nvidia-driver-580.119.02 1 NVidia graphics card binary drivers for hardware OpenGL rendering nvidia-drm-61-kmod-580.119.02.1403000 1 NVIDIA DRM Kernel Module nvidia-drm-kmod-580.119.02 NVIDIA DRM Kernel Module nvidia-kmod-580.119.02.1404000 1 kmod part of NVidia graphics card binary drivers for hardware OpenGL rendering sysrc kld list+=nvidia-drm During my testing period, the meta package installed incompatible versions of the serveral NVIDIA stuff. So I had to force installation of the proper version. For the record, this went like this: pkg -N install nvidia-drm-kmod ... nvidia-driver: 580.95.05 FreeBSD nvidia-drm-61-kmod: 580.95.05.1403000 FreeBSD nvidia-drm-kmod: 580.95.05 1 FreeBSD nvidia-kmod: 580.105.08.1403000 FreeBSD-kmods ... pkg install nvidia-drm-kmod-580.95.05 1 nvidia-kmod-580.95.05.1403000 ... nvidia-driver: 580.95.05 FreeBSD nvidia-drm-61-kmod: 580.95.05.1403000 FreeBSD nvidia-drm-kmod: 580.95.05 1 FreeBSD nvidia-kmod: 580.95.05.1403000 FreeBSD ... A reboot was performed to ensure I configured everything properly. The NVIDIA card was luckily identified and connected properly. pciconf -lv | grep -B3 display vgapci0@pci0:0:2:0: class=0x030000 rev=0x0c hdr=0x00 vendor=0x8086 device=0x4628 subvendor=0x8086 subdevice=0x2112 vendor = 'Intel Corporation' device = 'Alder Lake-UP3 GT2 UHD Graphics ' class = display -- vgapci1@pci0:5:0:0: class=0x030000 rev=0xa1 hdr=0x00 vendor=0x10de device=0x2805 subvendor=0x19da subdevice=0x7717 vendor = 'NVIDIA Corporation' device = 'AD106 GeForce RTX 4060 Ti 16GB ' class = display dmesg | grep -C 5 -i nvidia nvidia1: