How to install R on the Parallella (ZedBoard)

Moderator: censix

How to install R on the Parallella (ZedBoard)

Postby censix » Wed Jun 12, 2013 8:01 pm

This post will walk you through the R installation process. The parallella ships with a pre-installed Ubuntu version by Linaro.org and in theory, it would be possible to install R binary packages from the linaro.org package repository (package name: "r-base-core"). I have however opted for building and installing R form source, for two reasons. 1) its easy! 2) If in the future we manage to use the E16/64 through a properly compiled linear algebra library for R, then we will have to rebuild R with some specific options for that, so we might as well start doing this right away. Ok lets begin.

We place ourselves on the parallella via ssh. We need to be able to download stuff, so you should have set it up with a working network connection. Get the R sources from any of the R-project mirror servers

Code: Select all
wget   http://stat.ethz.ch/CRAN/src/base/R-2/R-2.15.1.tar.gz
tar -zxf R-2.15.1.tar.gz
cd R*


install the packages necessary for building R, i.e. a fortran compiler and some other stuff.

Code: Select all
sudo apt-get install bison
sudo apt-get install gfortran
sudo apt-get install libreadline-gplv2-dev


We are going to build a headless R, meaning no x11 graphical display.

Code: Select all
./configure --with-x=no


If configure terminates with an error here, check the log and see what other packages you need to install. I only needed to get the three packages mentioned here.
Now build the whole thing. (The parallella will need 30-45 minutes to do this, so relax :)

Code: Select all
make


You will get some warning messages during the build process that relate to missing sample data files needed for running the extensive test-suite that R comes with. Just ignore these warnings.
Now for a system wide installation do

Code: Select all
sudo make install


If you dont want a system-wide install (sometimes there are good reasons for that) just add the bin/ directory to your PATH and you should be good to go.

Code: Select all
export PATH="/home/yourself/R-2.15.1/bin:$PATH"


Voila, we are done. Start R by typing

Code: Select all
R


Screenshot1.png
Screenshot1.png (63.92 KiB) Viewed 23211 times


Soren
http://censix.com
Last edited by censix on Fri Jun 14, 2013 6:45 am, edited 1 time in total.
censix
 
Posts: 49
Joined: Sun Dec 16, 2012 7:54 pm
Location: europe

Re: How to install R on the Parallella (ZedBoard)

Postby ysapir » Wed Jun 12, 2013 8:27 pm

Looks great, thanks.

Do you know where in the R's source would the math library be, and how to interface with it (in terms of required data structures, etc.)?
User avatar
ysapir
 
Posts: 393
Joined: Tue Dec 11, 2012 7:05 pm

Re: How to install R on the Parallella (ZedBoard)

Postby censix » Thu Jun 13, 2013 9:35 am

Yaniv

I would look into the R source tree somewhere here

R-2.15.1/src/modules/lapack/

The configure flags needed to use an external BLAS are probably something like

./configure --enable-BLAS-shlib --enable-R-shlib .....

(taken from this nice document)
http://www.rochester.edu/college/gradst ... g/BLAS.pdf
censix
 
Posts: 49
Joined: Sun Dec 16, 2012 7:54 pm
Location: europe

Re: How to install R on the Parallella (ZedBoard)

Postby aolofsson » Thu Jun 13, 2013 12:56 pm

censix,
This is really awesome. R is a big deal! Do you know how much speed up we expect from an optimized BLAS implementation? (I am sure someone has already done the benchmark using GPUs). Next up..Octave. :D
Andreas
User avatar
aolofsson
 
Posts: 1005
Joined: Tue Dec 11, 2012 6:59 pm
Location: Lexington, Massachusetts,USA

Re: How to install R on the Parallella (ZedBoard)

Postby censix » Thu Jun 13, 2013 9:14 pm

Andreas

good to know this is useful to others. It certainly is to me.
I personally dont have any benchmark numbers for GPU accelerated R, but am sure they are out there somewhere.
Octave yes ... or Python...we just need to find an appropiate Guru. :ugeek:

Soren
http://censix.com
censix
 
Posts: 49
Joined: Sun Dec 16, 2012 7:54 pm
Location: europe

Re: How to install R on the Parallella (ZedBoard)

Postby juanlp » Thu Jun 27, 2013 2:50 am

Thank you for this guide. It's fantastic to see R running on Parallella (big yay)

However, R is a high memory demanding environment, especially when dealing with big chunk of data or large simulation. Do you have any suggestion on how to overcome this?

I wonder if in the future Parallella will support extendable memory banks? :D

Cheers
juanlp
 
Posts: 4
Joined: Thu Jun 27, 2013 2:44 am

Re: How to install R on the Parallella (ZedBoard)

Postby timpart » Thu Jun 27, 2013 6:30 am

ysapir wrote:Do you know where in the R's source would the math library be, and how to interface with it (in terms of required data structures, etc.)?


If you are referring to the the BLAS (Basic Linear Algebra Subprograms) API which can switched in R for a different implementation there is a specification here http://www.netlib.org/blas/blast-forum/ and more information here http://www.netlib.org/blas/

Looks promising for acceleration, especially the higher levels which involve more calculation.

Tim
timpart
 
Posts: 302
Joined: Mon Dec 17, 2012 3:25 am
Location: UK

Re: How to install R on the Parallella (ZedBoard)

Postby ysapir » Fri Jun 28, 2013 5:38 pm

So, in order to effectively accelerate R on Parallella, we'd need a port for the BLAS library for the Epiphany. Good to know.
User avatar
ysapir
 
Posts: 393
Joined: Tue Dec 11, 2012 7:05 pm

Re: How to install R on the Parallella (ZedBoard)

Postby timpart » Fri Jun 28, 2013 6:37 pm

I'm no expert on this but it seems BLAS is a de facto standard and there are many implementations. R comes with a basic one bundled in. This article http://www.r-bloggers.com/faster-r-through-better-blas/ explains more, but pours cold water on the idea it is a universal panacea, as not all R routines can make use of the library. At that point you either start to rewrite R, or make use of its ability to call external stuff you've written separately.

There is some hope though.

Tim
timpart
 
Posts: 302
Joined: Mon Dec 17, 2012 3:25 am
Location: UK

Re: How to install R on the Parallella (ZedBoard)

Postby censix » Fri Jun 28, 2013 8:49 pm

Hi

all that is needed is a BLAS library that uses the epiphany, i.e. through OpenCL. In another post I have suggested that we could use the "viennacl" for this.

Some clarifications:
This BLAS library does in no way have to be specific to R !
In addition, with a few additional ./configure flags, R can be compiled in a way so that it uses an external (epiphany driven) BLAS library. In that scenario, again, R does not care how the BLAS library does the calcuations.

For comparison:

1) Lets say you have an nvidia graphics card and install the cuda/opencl capable dirvers for it. These drivers come with a library called "cuBLAS" which implements BLAS routines using the nvidia GPU though cuda.

2) Lets say you have an ati graphics card and install the opencl drivers. Then again, these dirvers come with a library called "libclamdblas" that implements BLAS routines using the ati GPU.

In both scenarios, 1) and 2) it is possible to configure R so that it will use 'cuBLAS' or 'libclamdblas' instead of its own built in BLAS library, therby using the GPUs to accelerate almost all basic R calculations!

So coming back to the original point. If someone manages to create a standard BLAS implementation of as many levels as possible (1-3) using the epiphany processor ... we have won the game! Like I said. Viennacl look like a very promising starting point.
censix
 
Posts: 49
Joined: Sun Dec 16, 2012 7:54 pm
Location: europe

Next

Return to R

Who is online

Users browsing this forum: No registered users and 1 guest

cron