installing R 2.13.1 on Amazon EC2′s “Amazon Linux” AMI #rstats

Condensed from this post (and comments) on David Chudzicki’s blog, tweaked, and updated for R-2.13.1.

Assumes you’re starting with a virgin “Amazon Linux” AMI. I picked “Basic 64-bit Amazon Linux AMI 2011.02.1 Beta” (AMI Id: ami-8e1fece7) because it was marked as free tier eligible on the “Quick Start” tab of AWS’s “Launch Instance” dialog box:

$ sudo yum -y install make libX11-devel.* libICE-devel.* libSM-devel.* libdmx-devel.* libx* xorg-x11* libFS* libX*  readline-devel gcc-gfortran gcc-c++ texinfo tetex

$ wget http://cran.r-project.org/src/base/R-2/R-2.13.1.tar.gz

$ tar zxf R-2.13.1.tar.gz && cd R-2.13.1
$ ./configure && make

$ # make coffee... or finish your PhD thesis... (yes, it takes that long)
[...]
$ # finally, if all is well:

$ sudo make install

$ cd
$ R --version
R version 2.13.1 (2011-07-08)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-unknown-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License version 2.
For more information about these matters see

http://www.gnu.org/licenses/.

As always, refer to the Installation and Administration manual for details and options.

If you want to install RCurl, or anything which depends on it like twitteR, you’ll need to install libcurl & friends first:

$ sudo yum -y install libcurl libcurl-devel
About these ads

29 Responses to “installing R 2.13.1 on Amazon EC2′s “Amazon Linux” AMI #rstats”

  1. Dirk Eddelbuettel Says:

    To me, there is value-added in the Debian / Ubuntu builds so I tend to recommend *against* the ‘configure; make’ step. In any event, Debian got R 2.13.1 yesterday and Ubuntu builds of R 2.13.1 are already on the CRAN site so there is no need to rebuild, especially if you feel that the builds takes so long.

    • Jeffrey Breen Says:

      Hi Dirk:

      I would love to hear more about what goes into the Debian/Ubuntu builds. I have used RHEL and CentOS in production for years, and am beginning to feel like the only one who hasn’t made the switch to Ubuntu yet.

      I’m trying out Amazon Linux on their first-year-free plan. It has rpm and yum (and no apt), so it looks like RH to me, but I noticed that the last R build for any RedHat was of 2.10.0 back in 2009. I guess there’s no demand for RH binaries. Wow — things have changed!

      I found what looks like a great AMI for scientific computing which Drew Conway make by adding a bunch of stuff, including R and Python libraries, to a Ubuntu 10 base from MIT’s STARDEV group. But it can’t be launched in a “micro” instance, so isn’t free tier eligible.

      If anyone has a suggestion for a good Ubuntu AMI which can run in a micro instance, I’m all ears. When I just looked, there are 1,296 public Ubuntu AMIs to wade through.

      Thanks,
      Jeffrey

  2. CHarlie Says:

    I’m following your instructions, but when I type the command “R”, I receive bash: r: command not found.

    Any suggestions?

    • Jeffrey Breen Says:

      Hi Charlie:

      You’re not giving me much to go on.

      If the error was bash: r: command not found., is it possible you tried to run lower-case “r” instead of upper case “R”?

      Otherwise, it sounds as if it didn’t install. Did you notice any error messages? What happened when you typed sudo make install? Did it build the R executable correctly in your working directory (e.g., R-2.13.1/bin/R)? If so, does it run?

      Jeffrey

      • Charlie Says:

        I actually installed it on a 32-bit machine (not sure if that would make a difference).

        I’ll try again on a 64-bit Amazon AMI and get back to you if I get the same message. I did use a capital R as well. I’m installing this using a putty interface that connects to my instance. I’ve had the same problems before, and I have no idea why it may be happening. I’m pretty green when it comes to Linux/Unix, so I appreciate the feedback.

  3. Charlie Says:

    Alright, so I just copied your instructions verbatim (copy + paste) on a brand new Amazon AMI x64 instance. I logged into the machine with PuTTy, then logged in as ec2-user, then did “sudo su” for root access.

    I followed the instructions to a T, but still received the same error.

    Any thoughts? I can always load up a pre-made image that contains R, but I like the feeling of actually getting things working myself.

    Cheers.

    • Jeffrey Breen Says:

      Hi Charlie:

      Compiling can be satisfying… or frustrating. I encourage you to learn about what each step does.

      If the ‘configure’ step completes successfully — do you see any error messages? — ‘make’ is the critical step during which all the code is compiled. If it runs successfully — again, look carefully for any error messages — you should find a working R executable in a ‘bin’ directory. Is it there? Does it run?

      Just like any diagnostic process, just break it down, step by step.

      Good luck!
      Jeffrey

    • David Says:

      Hi Charlie,

      Try typing “./R” instead. You may not have the current working directory in your search path.

      David

  4. Charlie Says:

    Well, I got it up and running, Jeffrey. Just in case anyone else has this problem, I logged into the Amazon AMI as ec2-user, then I would type “sudo su” to go to root. I left that step out and voila, I now have R on my image.

    Thanks for the guidance!

  5. Satyavrat Says:

    you were right! I had time to get a coffee and some tea and then some beer and then some lunch and it was still running the make command. hopefully i am good to go by dinner.

    excellent post though….really helpful!

  6. Pablo R. Says:

    Hi everybody, I’m R windows user, however I neen use it from a terminal consola ssh, and I have troubles for running R and load work area, may be someone can help me with the most common commands for this case.
    Thanks

    • Jeffrey Breen Says:

      Hi Pablo:

      Are you looking for R commands to load a saved workspace? (Try ?load in R).

      Are you ssh’ing into a linux box? Are you looking for help with linux commands? What sort of problems, specifically, are you having?

      Jeffrey

      • Pablo Ramon Says:

        Hi Jeffrey, Im using secure shell client consola for windows. I was able to overcome the problem of loading the workspace from the console, but the real problem is that the algorithm with simulations in the cluster have the same problem with my personal machine (insufficient RAM). ┬┐Is it necessary to include special commands in scripts to work in cluster, or should I install some additional package?.

        Thanks for your help
        Pablo

      • Jeffrey Breen Says:

        Hi Pablo:

        The terminology around EC2 can be confusing. While everything runs on Amazon’s cluster(s), if you’re just using EC2, you’re getting a single virtual server with a fixed amount of RAM. If you need more RAM (or CPU), they offer different instance sizes: from 613MB in a “micro” instance up to 68.4 in a “High-Memory Quadruple Extra Large Instance” (see http://aws.amazon.com/ec2/instance-types/). Of course, bigger instances cost more than smaller ones.

        There are a number of ways to split up your work onto multiple machines (virtual or otherwise), if your simulations are amenable to parallelization. If you’re interested in that kind of cluster, the High-Performance and Parallel Computing CRAN task view should give your Googling a good starting point.

        JD Long has come up with a very novel use of Amazon’s Elastic MapReduce service. JD’s an agricultural economist working in the insurance industry and needs to run a bunch of monte carlo simulations every month. EMR is Amazon’s hosted Hadoop service which is intended for big data. Nevertheless, JD uses it to spin up a bunch of nodes into a temporary cluster to execute his monthly simulations. He has developed and released the ‘segue’ package which I wrote about earlier this year: http://jeffreybreen.wordpress.com/2011/01/10/segue-r-to-amazon-elastic-mapreduce-hadoop/

        Hope that helps,
        Jeffrey

      • Pablo Ramon Says:

        Thanks Jeffrey

  7. Satyavrat Says:

    hey, I am back.

    My terminal kinda hangs for some reason. any tips on how long i should wait before i check if R is installed? (esp after the configure and make commands)

  8. Woody Lewis Says:

    This worked like a charm. Thank you!

  9. Madeleine Says:

    I was just gearing up to grunt through the installation but you spared me the trouble. Worked great.

    Thank you!
    Madeleine

  10. isomorphismes Says:

    Reblogged this on Human Mathematics.

    • Jeffrey Breen Says:

      Cool, thanks.

      I have since given up on Amazon Linux. There are a number of good CentOS AMIs and, thanks to the EPEL repository, installing R is once again the 1-line exercise it should be!

      Jeffrey

  11. isomorphismes Says:

    My girlfriend said rvm took forever and a half to install on an (ubuntu) EC2 AMI as well. How can these instances be fast enough to serve up the entire twittersphere and take so long to install programs?

  12. isomorphismes Says:

    So a year later, Amazon now has 64-bit Ubuntu 12.04 instances. sudo apt-get install r-base-core took about a minute.

    ubuntu@ip-10-85-33-229:~$ R --version
    R version 2.14.1 (2011-12-22)
    Copyright (C) 2011 The R Foundation for Statistical Computing
    ISBN 3-900051-07-0
    Platform: x86_64-pc-linux-gnu (64-bit)

    Yay!

    • isomorphismes Says:

      And I mean free-tier-eligible micro instances of Ubuntu 12.04.

      • Jeffrey Breen Says:

        That is progress. I’ve always been a Red Hat guy myself, so I tried to use Amazon Linux. This was last year, so it may be fixed by now, but there was a problem with some package dependency (related to Tcl/Tk, I think), so there was no easy way to install R.

        I now use CentOS images insteaf, and don’t compile anything anymore :)

  13. Tom Says:

    The Amazon Linux AMI added support for the R language in October – you can now simply “yum install R”!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 54 other followers

%d bloggers like this: