R and data.table on AWS
Asked Answered
S

3

12

This is a very strange error I am running into trying to install a specific R library on AWS EC2 instance (Amazon Linux AMI). A link in the AWS forums here, posted by someone else, actually highlights my issue well.

The main / relevant part of the error message is:

data.table.h:6:12: fatal error: omp.h: No such file or directory
#include <omp.h> 

I did some research (while I'm not sure), I think this is related to whether or not there is an OpenMP enabled compiler on the server. The data.table installation page on GitHub itself discusses this a bit here, but I'm not sure how to update or fix this on my EC2 instance.

Any help with this is appreciated.

EDIT - this is a new problem, as i was able to successfully install data.table on a previous, similar EC2 instance less than a month ago.

EDIT 2 - I got around this issue by taking a previous EC2 instance of mine with data.table already installed on it, and creating a custom AMI from it. By using this custom AMI when launching new instances, they already came with the data.table library installed. If I notice AWS resolve this issue on its own, I'll try to remember to come back and update this post!

Septicemia answered 2/2, 2018 at 6:12 Comment(5)
What do you have in ~/.R/MakevarsNortherner
I deleted the instance that I was struggling with, so I'm not sure what that file had in it.Septicemia
I found the following instructions and these worked for us: #48307751Gunsel
this had a similar answer: #48307751Isomagnetic
This answer may help: #48307751Isomagnetic
C
11

The problem here is that data.table doesn't play nice with the default gcc compiler (gcc72-c++.x86_64 gets installed as a dependency of R-devel.x86_64). Point R to an older version by adding

CC=gcc64

in ~/.R/Makevars. If you start from a "clean" Amazon Linux AMI this file doesn't exist and you can just type

mkdir ~/.R
echo "CC=gcc64" >> ~/.R/Makevars
Curtis answered 10/2, 2018 at 19:19 Comment(0)
C
10

For some reason setting CC=gcc64 in the ~/.R/Makevars did not work for me. R was still using default gcc to compile.

However there is another option. You can edit the Makeconf file that R uses during compilation directly. If you're using Amazon Linux the file location is /usr/lib64/R/etc/Makeconf. Once you locate the file the trick is just the same, that is to change the CC = gcc to CC = gcc64. You also might want to make sure that gcc64 is installed by running sudo yum install gcc64.

Casabonne answered 17/4, 2018 at 10:45 Comment(1)
sudo sed -i 's/CC = gcc -m64/CC = gcc64 -m64/g' /usr/lib64/R/etc/MakeconfWeekday
T
2

I have the following workaround.

1) Connect with ssh.

2) Download package source

wget https://cran.r-project.org/src/contrib/data.table_1.10.4-3.tar.gz

3) Install package

R CMD INSTALL data.table_1.10.4-3.tar.gz

This will install the package in the local package directory, not necessarily the one of the RStudio user(s).

4) Use .libPaths() in R and RStudio to figure out where packages are stored.

5) Copy package into the desired directory using sudo cp -R SOURCE DEST.

Remark: This is a workaround not a solution because you need to install each package manually this way, i.e. handling dependencies can be cumbersome, but at least data.table works now.

Tub answered 16/4, 2018 at 18:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.