Installing Rpud on Ubuntu 14.04

`rpud` is an R package which allows for R operations on your NVIDIA GPU with minimal coding effort. It’s an excellent package and well worth looking into.

Unfortunately, its installation is not so straightforward on Ubuntu 14.04 (at least it wasn’t for me). The package comes with a help file but this is pretty useless if you encounter some obscure error. I will outline what I did to overcome these difficulties below.

1. Install from source

Unfortunately, one of the fixes I found requires you to edit the configuration file, therefore the source is needed. Download the source from CRAN and use ‘tar -zxvf’ to unzip and extract it in a folder of your choice.

2. Read the INSTALL file

The INSTALL file instructs the user to set the R_LIBS_USER environment variable. Put this in your ~/.bashrc file and, if you do not feel like restarting the terminal, set it by simply typing ‘export R_LIBS_USER=[…]’ where […] will be your R library directory. In my case this was ~/R/x86_64-pc-linux-gnu-library/3.1/

3. You need to set configuration options during installation

The configuration file for rpud will set default paths, if not specified, which are probably not relevant for your system. This will be a problem, as the installation will not be able to find “nvcc”, the NVIDIA compiler, which is obviously a pretty basic thing which is needed when compiling using CUDA libraries! The install.packages command should therefore look like something as follows:

install.packages(“./rpud/”,type=”source”,configure.args = c(” ./configure –with-cuda-home=/usr –with-r-lib=/usr/lib/R/lib”),repos=NULL,verbose = T)

Note the –with-cuda-home and –with-r-lib flags. These need to be set accordingly. If ‘nvcc’ lies in ‘/usr/bin’ then the first flag needs to just be ‘/usr’. rpud, by default, assumes something different.

4. Edit the configuration file

This is probably the trickiest part. There are two problems with the configuration file. First,rpud will assume that is in $CUDA_HOME/lib64. This is not always the case (in my system is was in $CUDA_HOME/lib/x86_64-linux-gnu), so do a quick search for ‘lib64’ in the file ‘configuration’ and change accordingly if your is in a different directory. I had to do this change in four or five places.

Second, and this is harder to debug, rpud assumes a (deprecated or different?) g++ version which assumes the existence of a “-Wl” option.  My gcc version if 4.8.2 and does not know what -Wl means. When installing the package you will get repeated errors such as

g++: error: unrecognized command line option ‘-Wl’

In the configuration file the problem is with


I did NOT find a proper workaround for this. However, simply emptying RPATHFLAG seemed to do the trick. So in the end I simply set


Then the installation went through fine after this and rpud works like a charm once installed.