Install Vulkan on Raspberry Pi 4 - Q-engineering
Go to content
Install Vulkan on Raspberry Pi 4

Install Vulkan on a Raspberry Pi 4.


This page guides you through the installation of Vulkan on a Raspberry Pi 4. Vulkan is a low-level 3D graphics accelerator using a balanced mix of CPU and GPU instructions and optimized for parallel tasking with multiple CPU cores. Many platforms are already using Vulkan, and now the Raspberry Pi is on board too.

One important point to mention, the software is still under construction. All the hard work is done by Igalia's lago Toral. And that's not easy considering the lack of a detailed VideoCore VI datasheet. At the moment (Dec 2020), many tests have been successful. As a result of that, the Vulkan driver is merged with Mesa upstream, thereby getting an official status.

For those looking for a graphical improvement to their games on a Raspberry Pi 4, the Vulkan API is the best (and only) solution.
On the other hand, for all the people looking to use the Vulkan library to boost their deep learning frameworks, a big disappointment awaits. The API is not yet well equipped to perform tensor calculations. The required operations are currently not supported. Maybe the near future will bring us good news.

One last remark, the Vulkan API works only on the Raspberry Pi 4. The Raspberry Pi 3 has another VideoCore GPU on board which is incompatible with the version found on the Pi 4.

Version check.
Please check your operating system before installing Vulkan on your Raspberry Pi 4. Run the command uname -a and verify your version with the screen dump below.


The Vulkan API has a many dependencies. Please, install the list below.
# check for updates
$ sudo apt-get update
$ sudo apt-get upgrade
# install dependencies
$ sudo apt-get install libxcb-randr0-dev libxrandr-dev
$ sudo apt-get install libxcb-xinerama0-dev libxinerama-dev libxcursor-dev
$ sudo apt-get install libxcb-cursor-dev libxkbcommon-dev xutils-dev
$ sudo apt-get install xutils-dev libpthread-stubs0-dev libpciaccess-dev
$ sudo apt-get install libffi-dev x11proto-xext-dev libxcb1-dev libxcb-*dev
$ sudo apt-get install bison flex libssl-dev libgnutls28-dev x11proto-dri2-dev
$ sudo apt-get install x11proto-dri3-dev libx11-dev libxcb-glx0-dev
$ sudo apt-get install libx11-xcb-dev libxext-dev libxdamage-dev libxfixes-dev
$ sudo apt-get install libva-dev x11proto-randr-dev x11proto-present-dev
$ sudo apt-get install libclc-dev libelf-dev git build-essential mesa-utils
$ sudo apt-get install libvulkan-dev ninja-build libvulkan1 python-mako
$ sudo apt-get install libdrm-dev libxshmfence-dev libxxf86vm-dev libunwind-dev
$ sudo apt-get install valgrind libzstd-dev vulkan-tools vulkan-utils
$ sudo apt-get install ninja-build


With the dependencies installed, the Vulkan API can be built.
# remove old versions first
$ sudo rm -rf /home/pi/mesa_vulkan
# install meson
$ sudo apt purge meson -y
$ sudo pip3 install meson
# install mako
$ sudo pip3 install mako
# install v3dv
$ cd ~
$ git clone mesa_vulkan
# build v3dv (± 30 min)
$ cd mesa_vulkan

32 bit OS (armv7l)
$ CFLAGS="-mcpu=cortex-a72 -mfpu=neon-fp-armv8" CXXFLAGS="-mcpu=cortex-a72 -mfpu=neon-fp-armv8" \
  meson --prefix /usr \
  -D platforms=x11 \
  -D vulkan-drivers=broadcom \
  -D dri-drivers= \
  -D gallium-drivers=kmsro,v3d,vc4 \
  -D buildtype=release build

64 bit OS (aarch64)
$ CFLAGS="-mcpu=cortex-a72" CXXFLAGS="-mcpu=cortex-a72" \
  meson --prefix /usr \
   -D platforms=x11 \
   -D vulkan-drivers=broadcom \
   -D dri-drivers= \
   -D gallium-drivers=kmsro,v3d,vc4 \
   -D buildtype=release build

$ ninja -C build -j4
$ sudo ninja -C build install
# check your driver
$ glxinfo -B
If the installation was successful, the screen below shows all the relevant information after the $ glxinfo -B command.


Running some examples.
Time to do some testing with the famous Sasch Willem Vulkan demos.
As mentioned, the library is still under development, so not all examples work on the current version. But still, some very impressive pictures can still be drawn. Follow the commands below to install the demo.
# install a dependency
$ sudo apt-get install libassimp-dev
# download the demos
$ git clone --recursive  sascha-willems
$ cd sascha-willems
# download some fonts
$ python3
# build the demos
$ mkdir build
$ cd build $ cmake -DCMAKE_BUILD_TYPE=Debug  .. 
$ make -j4
Go into the build/bin folder with $ cd build/bin and run some examples like:
$ ./gears

$ ./computeraytracing

$ ./gltfscenerendering

$ ./indirectdraw

Deep learning with Vulkan.
We've done some disappointing tests with the Vulkan API used as a backend in various deep learning frameworks. Alibaba's MNN and Tencent's ncnn, both use Vulkan as an accelerator for their tensor calculations. However, the current Vulkan API for the Raspberry Pi 4 does not yet support all necessary operations. In practice, the performance drops by a factor of 5 when using the Vulkan backend. See the benchmarks below.
All times in mSec
The Raspberry Pi 4 with 2 GByte RAM was running at a default clock speed of 1500 MHz.
ncnn build with cmake -D CMAKE_TOOLCHAIN_FILE=../toolchains/aarch64-linux-gnu.toolchain.cmake -D NCNN_VULKAN=ON -D CMAKE_BUILD_TYPE=Release ..
Install 64 OS
Install 32 OS
Raspberry and alt
Raspberry Pi 4
Jetson Nano
Back to content