ComfyUI with Cuda on Freebsd

Installing ComfyUI and ComfyUI-Manager with Cuda on Freebsd using Podman with the freebsd-cuda project.


ComfyUI

ComfyUI-Manager

Freebsd Cuda project

Freebsd Cuda - ComfyUI

ffmpeg-rust-scripts

realesrgan-ncnn-vulkan

freebsd root config

freebsd-dotfiles

freebsd bin

pixaroma
 
When you try and pull down python libraries that depend on Cuda using the Linuxulator for example

Python can see your on Freebsd and so fails to pull down the wheels,
which are only built for Linux

Podman has options to specify the platform and os as linux
and because it a container this tricks libraries into thinking they are running on linux

And by mapping the Linuxulator libraries and using devfs rules to unhide the gpu from Freebsd into the Podman container
you dont need to install the nvidia driver in the container

So podman uses the freebsd kernel and nvidia driver with native performance
without the overhead you would get using virtualization

The other advantage is unlike bhyve you only need one gpu
you dont need to be rich and fork out for a second gpu to pass though to a bhyve vm

Also because you are using the wayland or x11 sockets you have hardware accelerated graphics
which isnt possible with a vnc connection

you would have buy another monitor to use with the byhve vm and pass that through to get hardware accelerated graphics

And the audio uses a pulseaudio socket so you get audio with no latency
and dont have to buy another audio device and pass it through to the vm

You also have dockerfiles and compose.yaml to automate building the podman images
which you can distribute, unlike a bhyve vm which has to be manually built

So in short

The container uses the nvidia driver and libraries from the freebsd host
so when you update the driver on the freebsd side it will continue working with podman container

You have native performance with no overhead and hardware accelerated graphics using wayland or x11 sockets
and audio with no latency using a pulseaudio socket

You can distribute podman containers and build them locally
which you cant do with a bhyve vm

The podman container uses your user id and guid from the freebsd host in the container
so all the files are owned by your user on freebsd

You can mount directories from freebsd into the container for file access
like mounting the downloads directory from freebsd with a firefox podman container

So when you download files using firefox running in a podman container
the downloaded files are in your downloads directory on freebsd and owned by your user on freebsd

Its free and requires no additional hardware

unlike bhyve where you would have to but another gpu, monitor and audio device
which is going to cost at least 500 pounds or so

There are some things that wont work with using the Linuxulator and Podman
because the kernel doesnt support the syscalls like python jax for example

But i have mamaged to get the following working

1) Firefox with hardware accelerated video and Widevine DRM support.

2) ffmpeg with hardware-accelerated nvenc encoding.

3) WhisperX audio transcription with Cuda acceleration.


4) Ollama using Cuda.


5) kokoro-onnx using Cuda.


6) ComfYU



I did get a comment on one of the videos from Dr Owain Kenway

The Head of Research & Development (Platform Technologies) within ARC at UCL.

Saying

It makes FreeBSD a viable platform for ML stuff with PyTorch/JAX etc. If I can find time (and a free GPU which is probably harder) I'm tempted to have a go on our private cloud platform since I have FreeBSD working there.

However i did try python jax and couldnt get it work which maybe due to the fact i have an old turing nvidia card
or it could be an issue with the linuxulator syscalls
 
Back
Top