With the announcement today of the Vulkan API specification, I just couldn’t resist helping you all get on your way to installing and building the LunarG Vulkan SDK along with running the sample Vulkan applications on Ubuntu 15.10 :). This should provide as a great starter point for anyone with an Ubuntu workstation and a compatible nVidia Vulkan-capable graphics card. This is one of my first Linux servicing posts, so please leave feedback if you can.
About Vulkan
What is Vulkan?
https://www.khronos.org/vulkan/
Vulkan is the cross-platform performance-driven OpenGL alternative. It’s important to understand that OpenGL and Vulkan are not competing technologies, but rather Vulkan satisfies a particular need within the graphics community for an efficient, cross-platform, parallel-possible graphics API. Vulkan was jump-started thanks to the generous donation of code and research from the AMD Mantle project, which helped guide both DX12 implementation and the Vulkan specification (along with many other gracious contributors and supporters all outlined on the Khronos website). Khronos group owns OpenGL and Vulkan, and we will continue to see growth in both Vulkan and OpenGL specifications in the coming years. OpenGL provides a rich, backwards compatible interface with many helper functions and features, and Vulkan provides raw power for a trade-off of more verbose integration of the API.
What is LunarG Vulkan SDK?
The LunarG Vulkan SDK is the official “wrangler”, if you will. Providing tools, libraries, loaders, and a concise SDK for Vulkan so that application development is easy. This was one of the weakest points of OpenGL, and I think the existence of the LunarG SDK is Khrono’s answer to this problem rearing it’s ugly (and unfortunately necessary) head again for Vulkan. I’m sure as the SDK grows more tools and samples will be added, but for now it provides a slew of sample applications, some basic test “is Vulkan functioning” applications, and helper libraries for creating your own Vulkan applications. Plus they use CMake as their build system (which is a big plus in my book). This SDK also has the vktrace and vkreplay commands for recording/playback of Vulkan instances (pretty cool! We won’t be looking at this in the blog post, but I recommend you guys try it out, it’s neat).
Installing Vulkan Beta Drivers
Installing the LunarG Vulkan SDK
In order to get started with Vulkan on Ubuntu, you should probably be running either Ubuntu 14.04 LTS or 15.10 (I use 15.10). We can install the LunarG Vulkan SDK without having the proper binaries for running a Vulkan instance. This ends up being the best thing to do because you can continually test to see if Vulkan is installed properly by running the vulkaninfo
command after a reboot.
- Download the latest Vulkan SDK from the LunarG Vulkan website (at time of writing, it is 1.0.3.1)
- The file will be of the form
vulkansdk-<os>-<arch>-<version>.run
In my case, the file wasvulkansdk-linux-x86_64-1.0.3.1.run
- The file will be of the form
- Before we install, we need some prerequisites. I’m assuming you want to build documentation and sample applications, so let’s target that.
1234567891011121314151617181920212223242526272829303132333435# First let's update our packages.# Be sure you've backed up since we're doing a dist-upgrade!sudo apt-get updatesudo apt-get upgrade# Next, we'll install the dependencies for the Vulkan SDK# Let's explore what each package is for...# Note: If you want to just install all packages, run this:# sudo apt-get install libglm-dev graphviz libxcb-dri3-0 libxcb-present0 libpciaccess0 cmake libpng-dev bison# libglm-dev is a math library that was made for OpenGL.sudo apt-get install libglm-dev# Creates charts and graphs for documentation.sudo apt-get install graphviz# lib X C bindings provides an interface to the X Windowing system.# Specifically, this is the Direct Rendering Infrastructure.sudo apt-get install libxcb-dri3-0# lib X C bindings provides an interface to the X Windowing system.# Specifically, this is the presentation extensionsudo apt-get install libxcb-present0# Provides PCI access. Not 100% sure why they need this?sudo apt-get install libpciaccess0# The build system for creating the libraries/tools.sudo apt-get install cmake# A library for parsing png files for samples and examplessudo apt-get install libpng-dev# Required for building libglslang.a (GLSL->SPIR-V compiler)sudo apt-get install bison - Move the Vulkan SDK to where you want to install it. The LunarG guide recommends putting it in a folder named vulkan in the home directory, but after installing the SDK will create a folder called VulkanSDK anyways, so it might just be better to install it directly to the home directory or something (that’s what I did).
12cd ~cp ~/Downloads/vulkansdk-linux-x86_64-1.0.3.1.run ./ - Next we will install the Vulkan SDK. On Linux systems, downloaded files must be granted permission to execute, so remember to chmod.
123chmod a+x vulkansdk-linux-x86_64-1.0.3.1.run./vulkansdk-linux-x86_64-1.0.3.1.run# Note: You may be prompted for your password to install. - After installation, you should have a few Vulkan programs at hand. The core one you’ll want to use to see if you have Vulkan working is called
vulkaninfo
. All it does it prints information about the Vulkan-capable devices on your machine. If you don’t have the beta drivers (and assuming the stable ones haven’t shipped yet), you should see that you get an error.
12vulkaninfo# ... VK_ERROR_INCOMPATIBLE_DRIVER ...
Installing the Vulkan Beta Drivers
Warning: This is extremely dangerous to do in a Linux environment if you don’t know what you’re doing. Expect entirely to run into problems, because this is no longer the “modern” way of installing/updating Linux graphics drivers, and is very error-prone. Back-up your work, and be prepared to be entirely annoyed as you trudge through the hell of installing a proprietary binary on an open-source operating system. You’ve been warned.
I should be fair. Installing nVidia drivers has gotten a whole hell of a lot easier with the Proprietary GPU Drivers PPA. The problem is, we can’t use that – the beta binary isn’t available on it. If you are patient, you can wait until Vulkan is merged into the stable branch for nVidia, but otherwise it’s not terribly difficult to install the proprietary binaries if you just can’t wait… You just have to do everything right, and know what to do when something goes wrong.
Honestly, I probably shouldn’t be telling you what to do here. I’m going to discuss what I did, and hopefully this works for others (as it did for me), and maybe some Linux bros can help me understand if I did the right thing. All we need to do is; Remove our current nvidia drivers, install the specific beta driver from the nVidia website, and then reboot.
Let’s do this.
- First, let’s download the beta Vulkan nVidia drivers from https://developer.nvidia.com/vulkan-driver. Make sure your GPU is listed as supported, or else this will be all for naught.
- In order to manually install the beta drivers, we first need to uninstall the current drivers. (They can’t be in-use). So we should probably stop the display manager to kill all x server instances.
123456789101112131415161718192021222324252627282930# Note: you will lose the ability to use your desktop.# Have the rest of the instructions available on your phone or tablet.# First we will move from our display manager to a tty.# Press <Ctrl>+<Alt>+<F1> to go to tty1.# Next let's stop the lightdm display manager.# Note: You may have a different display manager installed.# However, I believe lightdm is the default for Ubuntu.sudo service lightdm stop# Next we should uninstall our current nVidia drivers# Note: Added some comments from http://askubuntu.com/questions/206283/how-can-i-uninstall-a-nvidia-driver-completelysudo apt-get remove --purge nvidia-*sudo apt-get install ubuntu-desktop# Next let's be sure to install the linux source/headers.# This is needed for the nVidia kernel modulesudo apt-get install linux-source linux-headers-generic# Next run the installation of the nVidia driver# Agree to the terms...# If it can't run pre-install script, don't worry...# Accept that it's okay to install the kernel module...# Should probably enable x86 compatibility...# If asked to update the xconfig, say yes!chmod a+x NVIDIA-Linux-x86_64-355.00.26.runsudo ./NVIDIA-Linux-x86_64-355.00.26.run# Restart the computersudo reboot - After this, the nVidia beta driver should be installed correctly! You can test it by running
vulkaninfo
and observing that it finds vkDevices!

vulkaninfo, tri, and cube applications running!
Building LunarG Examples/Samples
There are a number of samples in the LunarG Vulkan SDK code. Building them is pretty simple with CMake. However, even without a knowledge of CMake, there are build scripts provided (so we’ll just use those). Simply run the following commands to build samples and examples:
1 2 3 4 5 6 7 8 |
# Go into the Vulkan SDK directory cd ~/VulkanSDK/<version>/ # Build samples ./build_samples.sh # Build examples ./build_examples.sh |
At this point you should have some applications in the following directories:
- ~/VulkanSDK/<version>/examples/build/
- cube – a program that draws a rotating cube with the LunarG logo.
- tri – a program that just draws a simple triangle.
- vulkaninfo – exactly what you think it is, this is where the vulkaninfo utility is built.
- ~/VulkanSDK/<version>/samples/build/API-Samples/
- A ton of simple applications, not all of them have output. They simply test the functionality of Vulkan and provide some code for you to learn from. These samples aren’t very interesting to look at, but the code is the important part here.
- ~/VulkanSDK/<version>/samples/build/Demos/Hologram
- Hologram – Probably the most interesting (but still, fairly simple) example. Hologram renders a bunch of objects floating around in space.
There are some rudimentary controls: Space stops and starts movement of the objects, Up and Down arrows zoom in and out.
- Hologram – Probably the most interesting (but still, fairly simple) example. Hologram renders a bunch of objects floating around in space.
Help! My Computer Won’t Boot!
Yes, the worst part about messing up an installation of the graphics driver is that you will fail to boot. If you notice that you are stuck at a blinking cursor for a really, really long time – the installation either failed or your xserver isn’t configured properly. No worries, we can fix this. Let’s start by booting to the recovery prompt.
- To boot to the recovery prompt, restart your computer and hold Shift while it boots just after the BIOS screen.
- This will bring you to the GRUB menu, select and hit enter on “Advanced options for Ubuntu”.
- This will give you even more boot options. Select the corresponding “Ubuntu, kernel ## (recovery mode)” and hit Enter.
- After some time, this will present you with the recovery menu (with a broken installation, this might take time to load).
- Enable Networking by hitting enter of network (probably easier to be plugged directly into a router for this).
- Drop into the root terminal by selecting root. This should prompt us at a terminal for a command.
- First let’s remount the filesystem to read/write so we can make changes.
1mount -o remount,rw / - Next, let’s remove our foobar’d nVidia install.
12cd Downloads./NVIDIA-Linux-x86_64-355.00.26.run --uninstall - If we want to install a working nVidia binary, we can.
12345678910# For most installations, you can just get currentapt-get install nvidia-current# For certain GPUs (more modern ones) you might need# a newer GPU driver. If you're on a System76 laptop...apt-get install system76-driver-nvidia# If you want to use a newer driver, try the ppaadd-apt-repository ppa:graphics-drivers/ppaapt-get update && apt-get install nvidia-<driverversion> - Reboot and you should be good again.
1reboot
Summary
Today we learned how to:
- Install an nVidia proprietary beta driver on Ubuntu.
- We built the LunarG Vulkan SDK and it’s samples/examples.
- We confirmed that our machine can run Vulkan.
- If we ran into an issue, we learned how to recover.
Until next time.
Thanks for this guide, helped me out a lot!!!
I ran into a few issues (on a freshly installed ubuntu 15.10 system), so I want to share the solutions with you:
1. If you can’t open tty1: http://askubuntu.com/questions/276694/cant-view-output-in-tty-ctrlaltf1-to-f6-dont-work-and-display-a-black-scr
2. I’ve additionally installed the following packages to be able to compile the sdk: libxcb-dri3-dev and libxcb-present-dev
Glad this proved useful, Random Citizen! (Good name choice by the way)
Yeah, I wasn’t going off a fresh install, so it’s entirely possible that this could be the case. Thanks for investigating and sharing your findings – these kinds of installs have so many little quirks with them.
If I were you I’d raise a bug in documentation with LunarG about the extra required packages for the sdk. I probably already had those packages, as I do a lot of development work on my system. It makes total sense that you’d need those -dev packages.
Regarding installing new graphics drivers, you can (on Ubuntu), use the graphics-drivers PPA to switch to the latest drivers “the modern way”:
https://launchpad.net/~graphics-drivers/+archive/ubuntu/ppa
The issue with your way is that the drivers don’t get updated from then on, so you would have to continuously repeat the above process.
I mentioned the use the ppa, in fact – you can see that I claim it’s usefulness for recovering your desktop if the installation goes south.
However, the specific binary that we want to install for Vulkan beta support (355.00.26) is unfortunately not available on the ppa. The closest is 355.00.11, which I don’t think has Vulkan support. I tried installing a later binary to see if the beta support carried through to newer versions (I installed 361 from the ppa), but Vulkan beta support was not there. This makes me think that the support is not in the mainstream binaries right now, and only this specific revision of the nVidia driver is enabled for Vulkan support (for Linux, for Windows it’s the same story, different version/revision).
This wouldn’t be a problem if the ppa had some specific build for this beta driver (e.g. nvidia-vulkan-beta) but it doesn’t, so we have to install things manually.
Of course, in a few months this article will be useless – Vulkan will be brought upstream into the latest nVidia drivers and it will be as simple as an
apt-get upgrade
, or at worstapt-get install nvidia-<version>
for the latest drivers supporting Vulkan.But it’s always good to point out the ppa, that thing is super useful – it’s just that it doesn’t help us in this case.
Pingback: Vulkan VS OpenGL | Ubutnu 14.04 | GTX 960 – Geek Till It Hertz
Watching your blog with interest in hopes of some rendering pipeline tutorials for Vulkan. I am really enjoying your blog.
Hey John,
Glad to hear this! I really want to do more graphics tutorials (specifically for Vulkan), but I think that my requirements might take me elsewhere… I’ll try to do an update post soon to talk about what I’ve been working on, but I don’t want to promise any specific content until I figure out whats next. I eventually will do more graphics tutorials, I just can’t promise when that will happen. Could be the next thing I do, or could be two side-projects from now.