You are here

Trying Vulkan on Linux CentOS/RHEL 7

Objectives : running 3D-accelerated Vulkan demos on Linux CentOS/RHEL 7.

Vulkan is the latest 3D graphics API, and is meant to supersede good ol' OpenGL after ~ 24 years of good use. There is a lot to write about "Why Vulkan ?", but let's just say that it allows better control onto the GPU, along with better performance (requiring you to write lots more of code, though ;) ).

One thing Vulkan definitely needs is hardware support. You need a Vulkan-compatible driver to use it, and on our beloved GNU/Linux, only Intel GPUs support it for now (it was added very recently, and only really works for 4 days now ;) ).

The following steps are only known to work with Intel GPUs >= HD Graphics 4200 (such as those found in relatively recent Lenovo laptops). Do not spam-mail me if it does not work with your configuration !

(all commands below are supposed to be run as root)

1) Upgrade the kernel to 3.10.0 rev.327

The first version of CentOS 7 shipped with Linux kernel 3.10.0 rev.123, which does not support memfd. As memfd is heavily used within Intel's Vulkan implementation, we first need to upgrade to the latest 3.10.0 rev.327.

To do this, you first define the 7.2.1511 repository as your current one, and then :

- simply upgrade to CentOS 7.2.1511 :
$ yum clean all
$ yum update

- or upgrade the kernel alone :
$ yum update kernel

Then reboot !
You can verify if it worked by issuing the following command (should return some text) :
uname -a |grep 327

2) Install the latest Mesa Vulkan stack

For various reasons, the first of all being stability, we won't be messing with CentOS "stock" X11 installation. Instead, we will be extracting an archive in a separate directory, containing :
- Mesa 11.3.0-devel (with Vulkan branch merged)
- Wayland/Weston 1.9.0 ;
- XWayland 1.8.3 ;

(Weston is a pretty small and self-contained display server ; we need XWayland, providing X11 emulation for Weston, because LunarG Vulkan SDK demos use X11)

Download : Mesa1130_Vulkan-CENTOS70.tar.bz2 (34.4 Mb)

Extract the archive in /opt :
mv Mesa1130_Vulkan-CENTOS70.tar.bz2 /opt
cd /opt
tar xfvj Mesa1130_Vulkan-CENTOS70.tar.bz2

And install some dependencies :
cd /opt/mesa-vulkan/share/el7
rpm -ivh llvm-libs*.rpm

(if you are not running CentOS 7.2.1511, but only updated the kernel, you also want to install these updated RPMs :
rpm -Uvh libdrm-2*.rpm libdrm-devel*.rpm
rpm -Uvh libxcb-1*.rpm libxcb-devel*.rpm
rpm -ivh libxshmfence-1*.rpm libxshmfence-devel*.rpm

3) Install the LunarG Vulkan SDK

LunarG provides a cross-platform Vulkan SDK, which provides various binaries and sample code.
To download it, click here, then scroll to the bottom, click on Linux, Download the Ubuntu package (no worries), agree to the license, and download the package to your home directory.

The package is normally only Ubuntu-compatible, but will work on CentOS 7 nonetheless. Do the following :
mv /opt
cd /opt

(ignore any error message here)

You will also need to download this : (1.86 Kb)
and install the following development packages :
yum -y install libxcb-devel cmake
cp FindXCB.cmake /usr/share/cmake/Modules/

4) Run Weston with Mesa-Vulkan and XWayland/DRI3 support

First, you have to totally stop X11. If you are using stock CentOS 7 with a standard GNOME installation, you can do so :
systemctl stop gdm

then prepare Weston for the first run (only need to do this once) :
ln -s /usr/share/X11 /opt/mesa-vulkan/share/X11
ln -s /usr/bin/xkbcomp /opt/mesa-vulkan/bin/xkbcomp

and then start it :
source /opt/

5) Validate Vulkan support

You can start a terminal by clicking on this icon on the upper left :

and work from here.

Then go to the Vulkan SDK, define its library path, and run the vulkaninfo binary :
cd /opt/VulkanSDK/

You should see a whole log with GPU capabilities !
(if you see "VK_ERRROR_INCOMPATIBLE_DRIVER" instead, your hardware is not supported...)

6) Compile the LunarG SDK examples

Do the following :
cd /opt/VulkanSDK/
mkdir build; cd build
export CFLAGS="$CFLAGS -I../../x86_64/include"
export LDFLAGS="$LDFLAGS -L../../x86_64/lib"
cmake .. -DGLSL_LANG_VALIDATOR=../../x86_64/bin/glslangValidator

7) Run the LunarG SDK examples

We will run the Xwayland server (X11 emulation for Weston) and the cube demo we just compiled :
Xwayland &

You should see the following :

Well done !

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Enter the characters shown in the image.