NVIDIA CUDA 7.5 on Fedora 23 with NVIDIA Optimus Technology

I have a Dell XPS 15 that has both Intel and NVIDIA graphics using NVIDIA’s Optimus Technology:

00:02.0 VGA compatible controller: Intel Corporation HD Graphics 530 (rev 06)
01:00.0 3D controller: NVIDIA Corporation GM107M [GeForce GTX 960M] (rev a2)

Getting CUDA 7.5 to work was straightforward using Bumblebee, as described on the Fedora Bumblebee Page. I used the managed proprietary option to get the latest NVIDIA driver for my system. Using both optirun and primusrun works, however on glxgears they report different numbers

$ optirun glxgears
10162 frames in 5.0 seconds = 2032.270 FPS

$ primusrun glxgears
292 frames in 5.0 seconds = 58.370 FPS
primus: warning: dropping a frame to avoid deadlock
primus: warning: timeout waiting for display worker

I installed the CUDA Toolkit using the dnf repository provided by NVIDIA. It is important to only install the Toolkit from this repository, not the version of CUDA that is provided since Bumblebee already configured an appropriate Optimus-ready NVIDIA driver. So, instead you can just run

sudo dnf install cuda-toolkit-7-5

Additional configuration works as specified in the User’s Manual and Getting Started Guides. I had trouble getting the examples to compile because Fedora 23, which I’m on, defaults to gcc 5.3.1 and, unfortunately, CUDA 7.5 requires gcc 4.9 or less. I compiled GCC 4.9 from scratch and then manually modified the makefiles of each sample I wanted to compile to point to “g++49” instead of “g++”. You’ll notice that I told the gcc configuration during build time to add the 49 suffix with the –program-suffix=49 option. Aside from that, compilation and execution were simple enough with two catches:

  • It was necessarily to override the library path to point to Bumblebee’s version of the cuda shared library instead of a 32-bit version that somehow ended up in /usr/lib.
  • Contrary to what the Bumblebee documentation suggests, you must use optirun or primusrun to execute the samples. I’m not sure if this is required on more basic programs yet.

So, that looks something like this for the nbody example:

LD_LIBRARY_PATH=/usr/lib64/nvidia-bumblebee primusrun ./nbody

cudaNBody_cropped

Renaming a volume group on Linux without a reboot

It is possible to rename a volume group on Linux without rebooting the system and loading up a rescue image. This is very useful if, for example, you have a hard drive from a previous install from which you are trying to move data. The trick is to use the UUID of the volume group, not the volume group name, to rename it. Type as root:

vgrename -v <UUID of conflicting volume group> <New Name>

The “-v” will tell you exactly what is happening during the rename.

Mounting LVM volumes on Linux

To mount an LVM volume on Linux, first set the volume to the “active” state:

vgchange -ay

Mount the drive as usual. When finished, the drive must be unmounted and the command

vgchange -an

must be executed. Note that this could turn off all of your volume groups, so you should be careful and use a different command if you have more than one volume group.

Alternatively you can activate a specific volume group with the command

vgchange -a y <VolGroupName>

Fitting data to a function with Gnuplot

Put your x,y data in a file that Gnuplot can read, like a simple text file with an x,y pair on a line separated by a space.

Define the function, for example:

gauss(x)=a/(sigma*sqrt(2.*pi))*exp(-(x-p)**2./(2.*sigma**2))

Do the fit:

fit gauss(x) ‘gaussTest.dat’ via a, sigma, p

Plot the output with the data:

plot ‘gaussTest.dat’ with histeps, gauss(x)

Fixing annoying MOZILLA_FIVE_HOME errors

If you are having problems with SWT crashing because it can’t find MOZILLA_FIVE_HOME on Linux, make sure that you have xulrunner installed, check that it 32-bit or 64-bit to match the version of SWT that causes the error and add

MOZILLA_FIVE_HOME=/usr/lib/<path-to-xulrunner>

to your .bash_profile file.

For example, on the 64-bit version of Fedora 14, tools from IBM Rational will throw this type of error because they run on a 32-bit JVM with a 32-bit SWT. Running

yum install xulrunner.i686

and setting

MOZILLA_FIVE_HOME=/usr/lib/xulrunner-1.9.2

in .bash_profile fixes the problem.