Hologram application rendering a bunch of teapots and triangles

Installing nVidia Vulkan driver and LunarG SDK on Ubuntu 7


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?

http://lunarg.com/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 was vulkansdk-linux-x86_64-1.0.3.1.run
  • Before we install, we need some prerequisites. I’m assuming you want to build documentation and sample applications, so let’s target that.
  • 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).
  • Next we will install the Vulkan SDK. On Linux systems, downloaded files must be granted permission to execute, so remember to chmod.
  • 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.

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.
  • 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!

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:

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 application rendering a bunch of teapots and triangles

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.
  • Next, let’s remove our foobar’d nVidia install.
  • If we want to install a working nVidia binary, we can.
  • Reboot and you should be good again.

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. OvO
  • If we ran into an issue, we learned how to recover.

Until next time. :)


Leave a comment

Your email address will not be published. Required fields are marked *

7 thoughts on “Installing nVidia Vulkan driver and LunarG SDK on Ubuntu

    • Trent Post author

      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.

    • Trent Post author

      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 worst apt-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. :/

  • John Lagerquist

    Watching your blog with interest in hopes of some rendering pipeline tutorials for Vulkan. I am really enjoying your blog.

    • Trent Post author

      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. :/