kaeru


"Stuff I'm working on ..."

Getting Started with DaVinci Resolve Linux on AMD and Ubuntu Linux

by kaeru published 2023/12/28 13:30:00 GMT+8, last modified 2024-12-08T01:08:08+08:00
Quick guide into getting DaVinci Resolve working on Linux and AMD open source drivers

DaVinci Resolve Linux 18.6 on Ubuntu Linux Desktop

Important Update:

- DaVinci 19.1 is currently crashing when any Fusion effect or plugin is selected. Stay with 19.0.3 until it is resolved.
- AMD's rocm 6.3 setup installs duplicate OpenCL ICD profiles. Delete all amdocl64 duplicates in /etc/OpenCL/vendors except amdocl64.icd

DaVinci Resolve is fast becoming the standard video editor for content creators whether you're making quick cuts or producing a full length feature movie or documentary. As a result, if you're getting started into video editing and production like me, then it also means access to a wealth of great tutorials and guides online.


Davinci Resolve was one of the first large professional video editing application to also support Linux. Earlier versions were quite specific on which versions of Linux and graphics cards/drivers it would work on. This isn't very practical if you already have a working desktop install like Ubuntu Linux. Also it only worked with Nvidia GPUs and their proprietary albeit very good, graphics drivers. With AMD GPUs or other distributions, you would get random quirks, like blank video preview screens or it just not loading up at all.

Currently however, it works well on AMD's open source driver stack.

It's not exactly plug and play experience, yet so here is a brief guide to getting DaVinci Resolve up and running on Ubuntu Linux with AMD's open source graphics drivers.

OpenCL support via rocm

DaVinci Resolve for AMD uses OpenCL to accelerate video features, especially for rendering. You will want to have this feature. While Rocm is associated with AMD's much maligned efforts at getting an open source compute and AI stack working on Linux, it does have a stable and supported GPU OpenCL driver and libraries for AMD RDNA, RDNA 2 and RDNA 3 consumer cards. Installing this also means you get OpenCL support for your GPU card which works great with other applications like Darktable for photo editing.

The official instructions for the latest version of Rocm for Ubuntu can be found here. The installer now has configuration options for different use cases and not just for AI/ML. HIP, graphics and OpenCL are the use cases you proabably want for desktop media editing. Although Resolve only needs OpenCL, HIP and graphics will also install needed libraries for Blender and general hardware video encode and decode application support on Linux.

Quick install:

wget https://repo.radeon.com/amdgpu-install/latest/ubuntu/jammy/amdgpu-install_6.1.60101-1_all.deb
sudo apt install ./amdgpu-install_6.1.60101-1_all.deb sudo apt install "linux-headers-$(uname -r)" "linux-modules-extra-$(uname -r)amdgpu-install --usecase=hip,graphics,opencl sudo amdgpu-install --usecase=hip,graphics,opencl

You might get some issues with modules not found if you're using a low-latency kernel in which case, run `uname -r` which should give you your current kernel `6.5.0-14-lowlatency`

If so run the third line separately

sudo apt install "linux-headers-$(uname -r)"
sudo apt install linux-modules-extra-6.5.0-14-generic

Where the 6.5.0-14 matches your current kernel from the first command

Reboot.

To test that OpenCL is working, type clinfo and you should get 2 platforms listed, one your CPU and the second your GPU.

~$ clinfo 
Number of platforms 2

Installing Davinci Resolve

Head on over to their website and download DaVinci Resolve (free version).

The installer isn't packaged for Debian and if you would like to cleanly install, upgrade and maybe remove it in future, you probably want to to install as a debian package, there is a great utility called `MakeResolveDeb`and I recommend you install it.

Download the latest version there https://www.danieltufvesson.com/makeresolvedeb

The instructions on how to use it and install DaVinci Resolve as a Debian package are at Daniel's website.

Unable to start and problems with libraries

On newer versions of Ubuntu Linux, you might find that DaVinci Resolve won't start. This is most likely due to problems with linked libraries bundled with DaVinci. You will need to use LD_PRELOAD environment variable to make it use the system libraries.

LD_PRELOAD=/lib/x86_64-linux-gnu/libglib-2.0.so.0:/lib/x86_64-linux-gnu/libgio-2.0.so.0:/lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0:/lib/x86_64-linux-gnu/libgmodule-2.0.so.0 LD_LIBRARY_PATH=/opt/rocm/lib /opt/resolve/bin/resolve

Audio Sync Issues

Pipewire is now default audio system on Linux and DaVinci Resolve has a strange quirk that delays audio by 1 sec that requires a specific override just for the app.

It's now in the default installs, but if it isn't in yours, you'll need to add this in /etc/pipewire/client-rt.conf

# client specific properties
alsa.rules = [
    {   matches = [ { application.process.binary = "resolve" } ]
        actions = {
            update-props = {
		alsa.buffer-bytes = 131072
            }
        }
    }
]

Setting up desktop application launcher

With your favorite editor, create a file in ~/.local/share/applications/com.blackmagicdesign.resolve.desktop

And fill it with the following and save:

[Desktop Entry]
Version=1.0
Type=Application
Name=DaVinci Resolve
GenericName=DaVinci Resolve
Comment=Revolutionary new tools for editing, visual effects, color correction and professional audio post production, all in a single application!
Path=/opt/resolve/
Exec=env LD_PRELOAD=/lib/x86_64-linux-gnu/libglib-2.0.so.0:/lib/x86_64-linux-gnu/libgio-2.0.so.0:/lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0:/lib/x86_64-linux-gnu/libgmodule-2.0.so.0 LD_LIBRARY_PATH=/opt/rocm/lib /opt/resolve/bin/resolve
Terminal=false
MimeType=application/x-resolveproj;
Icon=/opt/resolve/graphics/DV_Resolve.png
StartupNotify=true
Name[en_US]=DaVinci Resolve

You will now be able to search for Davinci and launch it via the application browser launcher.

Video Codec Support on Linux

The video codec support on Linux for the free version is very limited, unlike other platforms. You will get frustrated that the videos from your phone and camera only have audio after import.

Currently the two codecs that are known to work for me are DNxHD and Prores which can be converted using `ffmpeg`. The size for prores is much smaller then DNxHD, and 50% of the size of XAVC S 10bit at quality scale of 9.

ProRes

ffmpeg -i input.mp4 -c:v prores_ks -profile:v 3 -qscale:v 9 -acodec pcm_s16le output.mov

Prores conversion I got from another Davinci on Linux guide (flolu)

For convenience you can also do bulk conversion on command line with GNU Parallels eg. in the directory of your video files.

ls *.mp4 | 
parallel ffmpeg -i {} -c:v prores_ks -profile:v 3 -qscale:v 9 -acodec pcm_s16le {.}.mov

DNxHD

ffmpeg inputfile.avi -c:v dnxhd -vf "scale=1920:1080,format=yuv422p10" -b:v 175M -c:a pcm_s16le output.mov

Importing and exporting H264

Note even the paid Studio version has issues with importing AAC audio and can't export to H264 on Linux. So features such as integrated export to common social media accounts doesn't work. You will need to also convert it manually. Here's a simple script you could use. Save it in ~/.local/bin as convert-socmed or something. So you can easily type convert-socmed inputfilename outputfilename to convert your exported media to something that can easily be posted to social media.

#!/bin/bash
INPUT=$1
OUTPUT=$2 ffmpeg -i $INPUT -preset veryslow -vf scale=-2:1080 -c:v libx264 \
-profile:v main -maxrate 3500k -bufsize 3500k -r 25 -pix_fmt yuv420p \
-b:a 320k $OUTPUT

First Tutorials

You should now able to launch DaVinci Resolve and started with the excellent training materials from BlackMagic

https://www.blackmagicdesign.com/products/davinciresolve/training

As before, you'll need to convert the provided files first, before it can be imported on DaVinci Resolve Linux.

Hopefully this helps, and that this guide will be reduced and not even required in the near future.