aws / aws-iot-device-sdk-arduino-yun

SDK for connecting to AWS IoT from an Arduino Yún.
Apache License 2.0
163 stars 77 forks source link

Running out of memory on yun rev 2 while trying to install sdk #72

Open lomah001 opened 5 years ago

lomah001 commented 5 years ago

I'm trying to install the AWSIoTPythonSDK manually using pip on my yun rev 2 but I keep getting an out of memory error and not sure how to proceed. The stack trace is as follows:

Error [Errno 12] Out of memory while executing command python setup.py egg_info
Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
  File "/usr/lib/python2.7/site-packages/pip/commands/install.py", line 324, in run
  File "/usr/lib/python2.7/site-packages/pip/req/req_set.py", line 380, in prepare_files
  File "/usr/lib/python2.7/site-packages/pip/req/req_set.py", line 634, in _prepare_file
  File "/usr/lib/python2.7/site-packages/pip/req/req_set.py", line 129, in prep_for_dist
  File "/usr/lib/python2.7/site-packages/pip/req/req_install.py", line 439, in run_egg_info
  File "/usr/lib/python2.7/site-packages/pip/utils/__init__.py", line 667, in call_subprocess
  File "/usr/lib/python2.7/subprocess.py", line 390, in __init__
  File "/usr/lib/python2.7/subprocess.py", line 917, in _execute_child
OSError: [Errno 12] Out of memory

Any help would be greatly appreciated. The board is new and the reason I'm installing the SDK manually is that I couldn't install the distribute package using the guide. So I installed pip manually but now have this issue while trying to run pip install AWSIoTPythonSDK==1.0.0 and don't know how to proceed.

nienen commented 5 years ago

I have the same problem! Anyone help?

JeffreyYu2018 commented 5 years ago

You have to add an SD card:

https://www.arduino.cc/en/Tutorial/ExpandingYunDiskSpace

EDIT: Scratch that, I added the SD card and I got the same error.

kriscodes2 commented 5 years ago

Same issue here. I partitioned 4GB of additional space from the SD card. I restarted the board and IDE but no luck.

JeffreyYu2018 commented 5 years ago

Hey @grownanny I figured it out.

Error [Errno 12] Out of memory while executing command python setup.py egg_info
Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
  File "/usr/lib/python2.7/site-packages/pip/commands/install.py", line 324, in run
  File "/usr/lib/python2.7/site-packages/pip/req/req_set.py", line 380, in prepare_files
  File "/usr/lib/python2.7/site-packages/pip/req/req_set.py", line 634, in _prepare_file
  File "/usr/lib/python2.7/site-packages/pip/req/req_set.py", line 129, in prep_for_dist
  File "/usr/lib/python2.7/site-packages/pip/req/req_install.py", line 439, in run_egg_info
  File "/usr/lib/python2.7/site-packages/pip/utils/__init__.py", line 667, in call_subprocess
  File "/usr/lib/python2.7/subprocess.py", line 390, in __init__
  File "/usr/lib/python2.7/subprocess.py", line 917, in _execute_child
OSError: [Errno 12] Out of memory

You're getting this error because while the Arduino Yun has enough disk space now with the SD, it is running out of RAM. In order to install the AWSIoTPythonSDK, we need to allocate it some 'swap memory'. 8. You can read more information and a more in-depth tutorial about swap memory here, but I will be including abbreviated directions here for convenience. *

First, ssh into the Arduino Yun by typing ssh root@<yourarduinoname>.local. Then, in the terminal, run: free -m. You should see your current free memory:

             total       used       free     shared    buffers     cached
Mem:         59932      45652      14280         80      25124       2960
-/+ buffers/cache:      17568      42364
Swap:            0          0          0

Notice how there is no swap memory. To add swap memory, follow the next few steps.

Create an empty file to act as a swap file by running: dd if=/dev/zero of=/yunswapfile bs=1M count=512. This should take a bit of time and produce this output:

512+0 records in
512+0 records out

Designate the file as a Swap file by running: mkswap /yunswapfile Load the swap file for verifying by running: swapon /yunswapfile Verify everything is working so far by running: free -m. You should see swap memory has been allocated:

             total       used       free     shared    buffers     cached
Mem:         59932      45652      14280         80      25124       2960
-/+ buffers/cache:      17568      42364
Swap:       524284          0     524284

Now we need to make the swap permanent. Run vim /etc/fstab and add the following line to the fstab: /yunswapfile none swap sw 0 0 We now have enough memory to install the AWSIoTPythonSDK. However, we need to run two more steps, because otherwise, you'll get more errors.

Upgrade to the latest version of pip by running curl https://bootstrap.pypa.io/get-pip.py -o get-pip.pyand then python2.7 get-pip.py --force-reinstall. Upgrade the pip installation tools by running: pip install --upgrade setuptools. Finally, we can install the SDK. Run pip install AWSIoTPythonSDK==1.0.0. Check to see if it works using pip show AWSIoTPythonSDK.

Hopefully this helps a lot. I had to go through a lot of failed troubleshooting attempts and research before I finally stumbled onto that one article. More research then allowed me to finally install the SDK.

kriscodes2 commented 5 years ago

Thanks so much for the help! I just assumed it was storage memory not Ram.

On Thu, Jul 4, 2019, 7:17 AM Jeffrey Yu notifications@github.com wrote:

Hey @grownanny https://github.com/grownanny I figured it out.

Error [Errno 12] Out of memory while executing command python setup.py egg_info Exception: Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main File "/usr/lib/python2.7/site-packages/pip/commands/install.py", line 324, in run File "/usr/lib/python2.7/site-packages/pip/req/req_set.py", line 380, in prepare_files File "/usr/lib/python2.7/site-packages/pip/req/req_set.py", line 634, in _prepare_file File "/usr/lib/python2.7/site-packages/pip/req/req_set.py", line 129, in prep_for_dist File "/usr/lib/python2.7/site-packages/pip/req/req_install.py", line 439, in run_egg_info File "/usr/lib/python2.7/site-packages/pip/utils/init.py", line 667, in call_subprocess File "/usr/lib/python2.7/subprocess.py", line 390, in init File "/usr/lib/python2.7/subprocess.py", line 917, in _execute_child OSError: [Errno 12] Out of memory

You're getting this error because while the Arduino Yun has enough disk space now with the SD, it is running out of RAM. In order to install the AWSIoTPythonSDK, we need to allocate it some 'swap memory'. 8. You can read more information and a more in-depth tutorial about swap memory here http://mohanp.com/arduino-yun-extending-the-ram-with-swap-file/, but I will be including abbreviated directions here for convenience. * First, in the ssh terminal, run: free -m. You should see your current free memory:

         total       used       free     shared    buffers     cached

Mem: 59932 45652 14280 80 25124 2960 -/+ buffers/cache: 17568 42364 Swap: 0 0 0

Notice how there is no swap memory. To add swap memory, follow the next few steps.

Create an empty file to act as a swap file by running: dd if=/dev/zero of=/yunswapfile bs=1M count=512. This should take a bit of time and produce this output:

512+0 records in 512+0 records out

Designate the file as a Swap file by running: mkswap /yunswapfile Load the swap file for verifying by running: swapon /yunswapfile Verify everything is working so far by running: free -m. You should see swap memory has been allocated:

         total       used       free     shared    buffers     cached

Mem: 59932 45652 14280 80 25124 2960 -/+ buffers/cache: 17568 42364 Swap: 524284 0 524284

Now we need to make the swap permanent. Run vim /etc/fstab and add the following line to the fstab: /yunswapfile none swap sw 0 0 We now have enough memory to install the AWSIoTPythonSDK. However, we need to run two more steps, because otherwise, you'll get more errors.

Upgrade to the latest version of pip by running curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py and then python2.7 get-pip.py --force-reinstall. Upgrade the pip installation tools by running: pip install --upgrade setuptools. Finally, we can install the SDK. Run pip install AWSIoTPythonSDK==1.0.0. Check to see if it works using pip show AWSIoTPythonSDK.

Hopefully this helps a lot. I had to go through a lot of failed troubleshooting attempts and research before I finally stumbled onto that one article. More research then allowed me to finally install the SDK.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aws/aws-iot-device-sdk-arduino-yun/issues/72?email_source=notifications&email_token=ALDM64AQCBMCSKB4HW4XJ33P5YA6BA5CNFSM4HF3D35KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZHRCDA#issuecomment-508498188, or mute the thread https://github.com/notifications/unsubscribe-auth/ALDM64DQIB3JHSBKPJCF6NDP5YA6BANCNFSM4HF3D35A .