Ching-Chuan Chen's Blogger

Statistics, Machine Learning and Programming

0%

R with GPU

The GPU computing is very popular since its capability of parallel computing. The environment of ubuntu is adequate to try GPU computing and its setting is easier than in window. I introduce the installation of CUDA, nVidia driver and R packages of GPU.

First, we go over the installation of CUDA 6.0.

  1. Download the CUDA 6.0 installer: CUDA Download. In my case, I download the RUN file of Ubuntu 13.04.

  2. Remove the old drive of nVidia:

1
2
sudo apt-get purge nvidia
sudo apt-get autoremove nvidia-current
  1. Install compatible GCC compiler. If the version of GCC compiler is not below 4.7.3, please install GCC 4.7.3. You can do that in this way:
1
2
3
4
5
6
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.7 g++-4.7
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7 10
sudo update-alternatives --config gcc

Choose gcc-4.7 for installing CUDA.

  1. Install CUDA 6.0: Press alt+ctrl+F1 login tty1 and input following commands:
1
2
sudo stop lightdm
sudo bash cuda_6.0.37_linux_64.run -driver -toolkit -silent

At begin, I do not install the driver, then it cause I can’t implement the compiled program.

  1. Add some environment variables: Use your text editor to edit .bashrc (In my case, it is subl ~/.bashrc.) and add following lines into the files: (Notice whether your installation dictionary is the same as mine.)
1
2
3
4
5
6
7
export PATH=/usr/local/cuda-6.0/bin:$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-6.0/lib:/usr/local/cuda-6.0/lib64
export CUDA_INC_PATH=/usr/local/cuda-6.0/include
export CUDA_LIB_PATH=/usr/local/cuda-6.0/lib64
export CUDA_BIN=/usr/local/cuda-6.0/bin
export CUDA_HOME=/usr/local/cuda-6.0
export R_INC_PATH=/usr/local/lib/R/include

Then you can use CUDA and start to install R package gputools. Besides, if you want opencl, then you need to install opencl-headers (use apt-get) and you can install R package OpenCL. However, I did not install R package WideLM successfully. (Caused by unknown option Wl)

The R package rpud is updated, but it did not update in CRAN. You need go to its website to download. Follow its installation note, you can install it successfully. Next time I will try to install the R package HiPLARM.

My environment is ubuntu 14.04. My CPU is 3770K@4.3GHz and GPU is GTX 670. If you have some questions, you can reference following urls:

  1. R and GPUh
  2. Installing CUDA Toolkit 6.0 in Ubuntu 12.04 Linux
  3. How do I install gcc 4.7?
  4. R gputools
  5. rpud