nVidia GPUs: Fixing Power State Woes in Linux

This one is easy. I mean, embarrassingly easy.

A little background, however; in Linux, nVidia GPUs don’t appear to clock down properly, even when idle and not connected to a monitor. This is frustrating for several reasons:

  1. P0 (full power) state when ‘idle’ wastes power, which wastes money
  2. The cards idle hot (my GTX 1080’s, without this tweak, idle around 60°C, with tweak, idle around 35-40°C)
  3. The P0 state downshifts to P2 (approximately a 20% performance drop!) when under compute load (which is stupid, but apparently to protect consumer grade cards under sustained load)
  4. I expect my computers to do what I tell them

Fortunately, nvidia-smi, the system management interface, can come to your rescue, without needing Xorg or nvidia-settings or a GUI.

Pick your favourite text editor (VI(m), Emacs, nano, pico, Xed… Leafpad (*shudder*) and point it, with root privileges, to :


Then add:

/usr/bin/nvidia-smi -i 0,1 -pm ENABLED

To the file, just above exit 0, then save and quit. Log out and back in, and your GPUs will have persistence enabled, which will make sure they clock down appropriately.

The -i flag indicates which GPUs you want to instruct with this command, and the -pm flag just sets persistence mode to enabled.

There’s another trick to get the cards to sit at P0 state when in compute mode, but I’ll admit I’ve not tried it because mine already get plenty warm enough.

Discworld: The Colour of Magic

The Colour of Magic CoverI recently had the opportunity, due to a lengthy flight, to re-read The Colour of Magic, the first of the Discworld novels.

I had forgotten how much fun it was.

Sure, it’s not as polished as some of the later works in the series, but the characters are still vibrant and alive, even if somewhat finding their feet.

The film version, with David Jason (who is probably one of my favourite actors of all time) and Sean Astin, is also well worth watching. Although I preferred Jason as Albert, Death’s manservant, rather than Rincewind.


UEFI & Linux

I’ll do a longer post on this another time, going into the details of how to persuade Windows 10 Pro and Ubuntu 16.04/Mint 18(.1) (or other distro of choice that supports SecureBoot) to play nicely together with SecureBoot enabled and third party drivers so CUDA can actually… y’know, work.

But for right now, a quick PSA (that’s Public Service Announcement, not psa as in the gene family…):

I’ve not had Ubuntu get it quite right yet with the USB stick I used to install it from; it wants to format the USB stick, which naturally enough doesn’t work.

For the purposes of this, I’m going to assume you want to run an SSD (solid state drive) as you main system drive with a larger spinning rust HDD for bulk data storage. I’ve done various setups over the years, but this one seems to work the best.

Partitioning must be set manually (I’ll fire up Virtualbox and take some screenshots to demonstrate later) to the following…

EFI System Partition (512MB) Beginning of SSD
Swap Partition (16GB) End of SSD
/ (that’s ‘root’ and holds everything else) the rest of the SSD
/data all the HDD

You also need to set the installation target of the GRUB bootloader to /dev/sda1 (or whatever partition the EFI System Partition is) (not the MBR!) or the system won’t boot with EFI/SecureBoot enabled.

When Drupal Breaks After Updating

{{This post is a bit of a blast from the past, being somewhat historical. Well, I can’t change the publication date like I could in Drupal (I won’t go into the reasons I quit using Drupal just now) so it gets bumped up to 2017…}}

Since this keeps catching me out every time I haven’t had to update Drupal for a while, here’s the most common way that Drupal manages to “500 Internal Error” itself after an update:


One little hash can totally ruin my day (well, for about five minutes until I remember why exactly everything is broken…)

Find the line:

# RewriteBase /

and change it to read:

RewriteBase /

Job done. Simple, but incredibly annoying if not expected, as it doesn’t break the ‘main’ webpage… just every other page and link on the entire site.

NB: If you’re sensible and running a tight set of permissions on your .htaccess file, don’t forget to chmod it first so you can actually make changes, then chmod it back again when done; forgetting that last bit can be a Bad Thing™.

Stopping Drupal from Summarising Everything (Badly)

{{This post is a bit of a blast from the past, being somewhat historical. Well, I can’t change the publication date like I could in Drupal (I won’t go into the reasons I quit using Drupal just now) so it gets bumped up to 2017…}}

I absolutely abhor the “summary” or “teaser” view that Drupal insists on imposing on you by default when you exceed a certain number of lines when making an Article. It’s the most annoying thing in the world. Especially when it gives you the option for forcing a break, but then completely ignores you and does its own thing anyway.

Regardless, there is a method of fixing it:

In the Administration Menu, head for Structure, then Content Types. Click ‘Manage Display’, then ‘Custom Display Settings’, and uncheck ‘Teaser’.

This must be done for each Content type.

It doesn’t, however, stop Drupal from giving you the incredibly stupid “Summary” of the post above the post when you hit “Preview”. But that is a minor irritation.

If anyone has found a way to do this for all Content types across the whole site in one go, that would be great.

Python, PIP and Visual Studio

{{This post is a bit of a blast from the past, being somewhat historical. Well, I can’t change the publication date like I could in Drupal (I won’t go into the reasons I quit using Drupal just now) so it gets bumped up to 2017…}}

When Python moved to the ‘pip’ installer system, I was torn about it. On one hand, it sounded like a great idea – package management! Great! But so far I’ve spent a fair bit of time grumbling over its oddities and annoyances.

Trying to install Numpy, it just wouldn’t do it. It would always fail with, while not the most useless error message in the world (that is reserved for the wonderful “Error: no error”) one that could have been quite a bit less cryptic.

I recognise the file it’s talking about, because it’s part of Visual Studio.

It’s interesting that it’s complaining, because I have Visual Studio 2013 Community installed, and am slowly learning that… (shock)… I quite like it. But the issue is that Python 3.4 was compiled using Visual Studio 2010. And looks for vcvarsall.bat in one place and one place only.

Anyway, there are several options, most of which are simply unacceptable in my view.

“The internet” seems to think that installing Visual C++ 2010 Express, when I already have VS2013 installed is a sensible, (nay, essential!) thing to do. I disagree. So I refused to do it.

The next “internet suggestion” was install MinGW and point pip to it as a compiler. OK, but I’ve got a compiler already, I want to use that. While my dev environments tend to have a lot in them, I don’t need a Swiss Army Knife with 1001 tools – just a few will do me, thanks.

The second was use pre-compiled binaries. OK, I’ve done it before with things like PyMol – let me just take this opportunity to plug Christoph Gohlke’s superb collection – but it has to be possible to do this myself…

To that end, you can just do the following:

Create an Environment Variable for “VS100COMNTOOLS” (Visual Studio 2010 is version 10.0) which points at the same directory as “VS120COMNTOOLS”

Which works perfectly.

A New Job

So, I’ve moved on to newer pastures.

I’m not involved directly with magnetic resonance any longer, although that will always be close to my (scientific) heart. Being back in a wet lab, albeit while still doing a lot of computing related work, is exciting.

This blog/site/whatever-you-want-to-call-it won’t focus on my job. I’ll post now and again regarding curiosities encountered, minor challenges overcome (particularly when in respect to a reticent bit of code) but almost anything that catches my attention may be fair game.

Books, music, computing, science… perhaps a bit of sight-seeing if I go somewhere particularly worth sharing with others than close friends or family… all are good.

But if you just come for one or two posts, that’s fine too.

Of course, the remit might expand as time passes, but on that front… we shall have to see.

In the mean time, take care all.