Programming and Technology

By Robert Roos

I recently stumbled upon a problem with Vulkan on one of my laptops running a NVIDIA Optimus setup, that is two graphics cards running on the same computer where you depending on the workload switch between the integrated one (Intel) and the dedicated one (NVIDIA).

The problem was that after upgrading Ubuntu to the latest kernel (5.3.7 at the time of writing) and the NVIDIA drivers (440 at the time of writing) all Vulkan based games stopped working.

This is quite the problem, since for example Steam Play (Proton) uses Vulkan for most games. Running vulkaninfo in the terminal showed that Vulkan could not be initialized, even though all the files and dependencies were in order.

After some extensive searching i found a very easy fix that seems to solve the problem, although it seems it needs to be done after each time you have switched between the Intel and NVIDIA card through the NVIDIA X Server software.

Simply run sudo vulkaninfo in a terminal instance and the problem is solved. This points to the problem being a rights one, I have not been able to figure out the source of it. But the above workaround at least works for now.

I use Github for almost every programming project, both for work and personal projects. It's a great tool for version management and collaboration, there are of course other Git-based services such as Bitbucket. But Github has always been my favorite, now with unlimited private repositories even if you are a non-paying customer it has become even better.

To work with Github you don't really need a GUI, and more often than not if you are using a IDE such as Visual Studio or JetBrains Rider you will already have a built-in command-line/GUI hybrid tool built in.

With that said, I find that working with a dedicated GUI for Github at times just makes things a bit faster and easier, therefore I've been a user of Github Desktop for a very long time. It should be added that my main dev-setup has been Windows + Visual Studio for the longer part, but nowadays I've moved on to Linux and JetBrains Rider instead.

The good news is that Github Desktop is available on Linux as well for various distros, through this project: https://github.com/shiftkey/desktop

Go with the install instructions for your distro, if you are on a Ubuntu based distro the snap image is probably the easiest way to get started, just open up snap store and search for Github Desktop and install.

However

I've tested the (at the time of writing) latest release 2.1.0 on several Ubuntu-based distros and it's just not working. After installation through the snap store the following error is thrown:

user@user:~$ env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/github-desktop_github-desktop.desktop /snap/bin/github-desktop
/snap/github-desktop/63/app/github-desktop: symbol lookup error: /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0: undefined symbol: g_date_copy

This seems to be a bug that the developers are aware of and should be fixed in the future, until we are in the future the easiest solution for this is to head on over to: https://github.com/shiftkey/desktop/releases/tag/release-2.0.4-linux1 and download the 2.0.4 version (select the .snap package and download).

After downloading run the following in terminal:

snap remove github-desktop
snap install ~/Downloads/GitHubDesktop-linux-2.0.4-linux1.snap --classic --dangerous

Just change the path to where the downloaded file is located on your system.

This installs the 2.0.4 version of Github Desktop that runs without any issues. You can now login to Github through the GUI and start hacking away!

 

I run Ubuntu on my laptop and Elementary OS on my stationary computer as my daily driver. Linux overall has come a very long way in the last couple of years, much due to the explosion in open-source applications available. But also due to companies working harder to make their programs and games run on Linux (Steam, Lutris and JetBrains Rider the real MVP).

We are getting closer to linux going mainstream I think, especially with user friendly distros such as Ubuntu, Elementary OS, Fedora and of course Manjaro.

But there are still quite a few things to work out - I think the lack of GUI:s for a lot of "under the hood" settings still scares off a lot of users. For example, I realized yesterday when running an older single-threaded game through Lutris that I had bad performance (AMD Ryzen CPU). I checked the CPU frequency and found out that the governor for the CPU was set to "ondemand", which is good for most standard work/multi-threaded games. But in this case forcing the CPU to work at a higher frequency was the only solution to get an acceptable framerate. This however needed some scary terminal tinkering... well not that scary at all to be honest, let me show you.

Start off by opening a fresh instance of the terminal and run:

sudo apt-get install cpufrequtils

This installs the cpu freq tools we will be using to set the governor to performance mode. But before we do that, run the following command in the terminal:

cpufreq-info

This should render information about your CPU, look for the governor settings line and make sure it's not already set to "performance". Usually Ubuntu and other Debian distros sets the governor to "ondemand", so that is what you should be seeing here.

Next off, open another terminal instance (keep your previous open) and run the following command:

watch -n1 "lscpu | grep MHz | awk '{print $1}'";

This will render your current CPU min, max and current frequency. If you want you can try running a game or larger video to see it go up and down, but overall trying to stay closer to the minimum frequency than the maximum. This is due to the governor beeing set to "ondemand", which is trying to save power and generate less heat.

Let's crank up the performance. Run the following in your first terminal instance:

sudo bash -c 'for i in {0..11}; do cpufreq-set -c $i -g performance; done'

NOTICE! Make sure you set the number 11 to the amount of cores your CPU has minus one (since the count starts at 0). In my case I run a 12 core Ryzen CPU, therefore I need to set it to 11. If you have an 8 core CPU, you set it to 7 and so on. Then hit enter to run the script.

Now run:

cpufreq-info

And look for the governor once again, your should now see it set to "performance" instead of "ondemand".

Open up the second terminal instance again and you should now see your overall cpu frequency staying at a higher number, closer to maximum than minimum. Try running a game or large video again and see the difference (and feel the difference with higher FPS in games).

To return the governor to "ondemand" simply run:

sudo bash -c 'for i in {0..11}; do cpufreq-set -c $i -g ondemand; done'

And that's it!

Now there are a lot of ways to work with this, for example the one I've just shown. Another is to add this script to your ".bashrc" for easier execution in the future. You could also add it to the startup scripts for your distro to have it set the CPU to performance mode permanently. I won't go into this since I think switching manually is better and ondemand is what you probably should be running most of the time when not doing heavy work, it saves some power and that is always good.

I will however show how you can make the execution of the script easier through ".bashrc".

Open a terminal instance and run:

sudo nano ~root/.bashrc

This will open a editor, on a new line paste the following (again change 11 to the number of cores you have minus one)

function setgov ()
{
     for i in {0..11}; 
     do 
         cpufreq-set -c $i -g $1; 
     done
}

Press CTRL+X and you will be asked if you want to save the changes, save the changes and the editor will close.

You can now change your CPU governor by running the following in a terminal instance:

sudo bash
sudo setgov performance

And to set it back to ondemand:

sudo bash
sudo setgov ondemand

That's it, you now have a very simple way to crank up the performance when gaming or whatever else needs that extra kick. Good luck!