Install readr package on EC2 instance

Hi,
I am trying to install readr package (because I need kableExtra package) on an AWS EC2 instance.
But I keep receiving this error:

virtual memory exhausted: Cannot allocate memory
make: *** [Collector.o] Error 1

Isn't there a way to install it without having to increase the memory?
Thanks.
M

What EC2 instance are you running? Have you run $ top and seen what memory usage you're at before trying to install the package?

It's likely that you're already at the max.

1 Like

I am on the t2.small (2GB)

Here is the memory usage I have:

1

I do not know how to empty the memory on CentOs and did not find the answer

Hmmm. Perculiar, is there anyway you can run install whilst also running $ top?

I use tmux on my instances so I can split my terminal, it would be interesting to see if the memory usage of R actually hits the limit when its installing. You could just open two terminal windows.

Apart from that, you could try gc() after every time you install a package, but that's not very handy if you're doing them all in a install.packages(c(<list of things>)) way.

I just tried, you can see below:

Did you manage to run $ top alongside to see the real memory usage?

Other than seeing what that gives you, I'm assuming 2GB probably isn't enough unfortunately.

https://github.com/tidyverse/readr/issues/544 would suggest 2GB probably isn't enough, either try to download the binary as the solution near the bottom mentions or bump up your memory, hope this helps!

Yes I saw it but it is only for Ubunto not CentOs.
So yes I will have to bump up my memory and pay for the t2.medium
I hope it is possible to planning to stop and restart the instance each day so that I only run it for 2 hours per day for example, as I dont want my costs to explode !

You should be okay, are you within the Free Tier period? I'm currently running two t2.larges for about 4 hours a day and I'm incurring no charges...

If you don't want to use a bigger instance: https://builder.r-hub.io looks like you can download the source and compile it on this site, if you select advanced you can select CentOs. Probably worth a try!

1 Like

Upgraded to t2.small and it works now. Praying for a low cost ! Thank you @ciaranevans

1 Like

@Maverick hope it works out! You can set a alert on AWS to tell you immediately when you're incurring charges if you want to play it safe! But with careful uptime and usage you should stay under the limit :smiley:

I pay 10$ / month its worth it !

@ciaranevans How are you running two t2.larges without charges. Everything I see on AWS is that only t2.micro is free for 12 months. I have the same issue as the one above. Out of memory when trying to install the readr package. Running RStudio on AWS with the free t2.micro instance.

You can add swap memory to avoid this issue, this comands will add 3GB of swap memory to your instance.

sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=3072
sudo /sbin/mkswap /var/swap.1
sudo /sbin/swapon /var/swap.1
sudo sh -c 'echo "/var/swap.1 swap swap defaults 0 0 " >> /etc/fstab'

Thank you for the reply.
But I have no idea what that means. :frowning:
Add swap memory where? In the AWS Instance? If so where? In RStudio? If so, where and how? Before I try to install readr?
I'm using RStudio through AWS.
I don't know where that code should go?
What is sudo?
Thanks.

You should run those commands on a system terminal, then you would have enough memory to install readr on the R console.

Thank you. Can't get it work though. I get illegal numeric value.

Output from within Terminal:
(base) Kevins-Mac-mini:~ kevinwilliams$ sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=3072
Password:
Sorry, try again.
Password:
dd: bs: illegal numeric value
(base) Kevins-Mac-mini:~ kevinwilliams$

I'm on a Mac if that matters.
Thanks,
KW

You have tu run those commands on a terminal in the aws instance, what OS are you using for your instance?

Sorry, I don't know what you mean.

"You have tu run those commands on a terminal in the aws instance". I am not sure what that means. I have my terminal open. What does it mean to run on a "terminal in the aws instance."? I've found quite a few posts that show the same thing you have sent me, but they just say type it. Type it where if not in the terminal?
"what OS are you using for your instance?" I don't know what this means. I am running AWS in Safari on a Mac. Is that what you mean?