Blender and Nvidia and Linux, Oh My!

I have a bunch of graphics-related programs I want to use. These are: Wayland, Sway, Avidemux, and Blender. I also want to use multiple monitors. I also want to use my Nvidia GPU to help me with those. This is unfortunate, because Nvidia hates linux.

Where It All Started

Several months ago, I quit Ubuntu in disgust and switched over to Fedora. I decided to take the opportunity to switch to Wayland, a new graphics protocol, and Sway, a tiling window manager. This fixed a number of nagging screen tearing issues, and I was largely happy. Sway is based on wlroots, a Wayland compositor. This will be important later.

graphics protocol DE Drivers Works? What’s Broken
Wayland Sway Nouveau Yes nothing I know of

Where It All Went Wrong

A couple months ago, as a hobby, I picked up 3d modeling in Blender. Render times were slow, because I wasn’t using the GPU. I eventually looked into it, and Blender will only work with the proprietary Nvidia drivers. I had the open-source Nouveau drivers installed.

graphics protocol DE Drivers Works? What’s Broken
Wayland Sway Nouveau Yes nothing I know of
Wayland Sway Nouveau No Blender

Going South Fast

So I installed the proprietary drivers instead. The problem here is that Sway DOES NOT LIKE the proprietary drivers. You have to run Sway with a special flag to use them, and then agree not to file any bug reports. If you don’t use that special flag, Sway will refuse to run. This is because Sway is based on wlroots (remember that?) and wlroots only works with the Nouveau drivers.

This computer has an integrated Intel GPU in addition to the Nvidia one, and I ought to be able to tell sway to use that, but there’s no way to check it’s working and the sway early-exit only checks if the Nvidia drivers exist, not if they’re actually being used. I’m not sure the integrated GPU is powerful enough to run multiple external monitors anyway.

graphics protocol DE Drivers Works? What’s Broken
Wayland Sway Nouveau Yes nothing I know of
Wayland Sway Nouveau No Blender
Wayland Sway Nvidia No Sway

Hitting Reverse

Fine. Wayland is clearly not ready for this sort of workflow. I went back to Xorg. Googled my screen tearing issues, played around with vsync settings, tweaked a few other things, went back to i3 (the Xorg version of sway).

Lo and behold, Blender didn’t work! Some touchpad inputs were simply not registering. I couldn’t figure out how to fix that, so I went back to Wayland in defeat.

graphics protocol DE Drivers Works? What’s Broken
Wayland Sway Nouveau Yes nothing I know of
Wayland Sway Nouveau No Blender
Wayland Sway Nvidia No Sway
Xorg I3 Nvidia No Blender

If At First You Don’t Succeed, Redefine Success

I started cutting requirements. Gnome (and KDE) will work with the proprietary drivers - I don’t know why wlroots doesn’t copy that code, presumably they have a good reason - so I started using that. I tried a couple options at this point - sway inside Gnome, i3 inside gnome using xwayland, but nothing really worked so I tweaked Gnome until it was close enough to what I wanted.

At this point, I also considered using a VM with GPU passthrough. I found this article, got as far as the table of contents and moved on. You will too.

Whack-A-Yak

So we’re good, right? WRONG. I also do video editing using Avidemux, a free video editor. That stopped working under Gnome. I could open a file and hear sound, but not see video. Running it under Xorg via Xwayland meant I could see the video, but it would crash trying to edit files. Telling it to use hardware acceleration for decoding videos meant it would hardlock my system and require a reboot (this happened four times trying to write this section.) I got the video out by prepping it under Xorg, and exporting it with Wayland.

graphics protocol DE Drivers Works? What’s Broken
Wayland Sway Nouveau Yes nothing I know of
Wayland Sway Nouveau No Blender
Wayland Sway Nvidia No Sway
Xorg I3 Nvidia No Blender
Wayland Gnome Nvidia No Avidemux

Back To Where We Started

Back to Blender! Rendering is still slow. Turns out, CUDA (Nvidia’s cross-platform GPU interface) is a separate install. Even though I installed a package with CUDA in the name. Turns out, CUDA requires an out-of-date GCC version or it won’t work. Turns out, CUDA also requires you to pretend you’re running an out-of-date Fedora version (source). Remember how I said Nvidia hates linux? Yeah.

graphics protocol DE Drivers Works? What’s Broken
Wayland Sway Nouveau Yes nothing I know of
Wayland Sway Nouveau No Blender
Wayland Sway Nvidia No Sway
Xorg I3 Nvidia No Blender
Wayland Gnome Nvidia No Avidemux
Wayland Gnome Nvidia No Blender

So I installed Homebrew, installed gcc@12, and now I have to set a special environment var every time I run blender so it knows to tell CUDA to use gcc-12. But hey! At least I’m finally using my GPU.

False Hope

So we’re good right? WRONG. Blender is SLOW. Not just in rendering, in everything. After I did a render (a small one), even just moving the viewport was slow and liable to lock up. I could change the settings all I wanted, but nothing made a difference. Not even restarting Blender! Rendering attempts repeatedly crashed with an OOM error, when they didn’t hardlock my machine entirely.

graphics protocol DE Drivers Works? What’s Broken
Wayland Sway Nouveau Yes nothing I know of
Wayland Sway Nouveau No Blender
Wayland Sway Nvidia No Sway
Xorg I3 Nvidia No Blender
Wayland Gnome Nvidia No Avidemux
Wayland Gnome Nvidia No Blender
Wayland Gnome Nvidia + CUDA No Blender

To skip over much googling (because it didn’t help) I noticed that Gnome has a power saving setting that’s set to “balanced” by default. Changing it to “performance” FINALLY made blender run smoothly.

Conclusion

What still doesn’t work? Firefox playing a video fullscreen on a projector has stuttering issues (not a good look on a date). I recall messing around with vsync, maybe that did something. A couple of my custom systemd services don’t work. I think this is a Gnome issue where it starts systemd services in a different order when it comes to graphical ones. Oh well. What is a Linux system without a few quirks?

graphics protocol DE Drivers Works? What’s Broken
Wayland Sway Nouveau Yes nothing I know of
Wayland Sway Nouveau No Blender
Wayland Sway Nvidia No Sway
Xorg I3 Nvidia No Blender
Wayland Gnome Nvidia No Avidemux
Wayland Gnome Nvidia No Blender
Wayland Gnome Nvidia + CUDA No Blender
Wayland Gnome + Performance mode Nvidia + CUDA Yes Firefox (but only a little)
Want more? Subscribe via RSS. Want to talk about cleaning up your codebase? Email me! Otherwise, happy coding!
Originally published on January 4, 2024.