Uncategorized

TensorFlow installation notes

Asked 
Active 3 days ago
Viewed 42 times
0

Help I’m new to this and I cannot install Tensorflow on Raspberry Pi 4 4GB. Current Python version: Python 3.7.3 Pip version : pip 19.2.3

I tried typing

pip install --upgrade tensorflow

and

pip3 install --user --upgrade tensorflow 

and

pip install tensorflow

All of them cannot work and return similar error.

ERROR: Exception:
Traceback (most recent call last):
  File "/home/pi/.local/lib/python2.7/site-packages/pip/_internal/cli/base_command.py", line 188, in main
    status = self.run(options, args)
  File "/home/pi/.local/lib/python2.7/site-packages/pip/_internal/commands/install.py", line 345, in run
    resolver.resolve(requirement_set)
  File "/home/pi/.local/lib/python2.7/site-packages/pip/_internal/legacy_resolve.py", line 196, in resolve
    self._resolve_one(requirement_set, req)
  File "/home/pi/.local/lib/python2.7/site-packages/pip/_internal/legacy_resolve.py", line 359, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "/home/pi/.local/lib/python2.7/site-packages/pip/_internal/legacy_resolve.py", line 307, in _get_abstract_dist_for
    self.require_hashes
  File "/home/pi/.local/lib/python2.7/site-packages/pip/_internal/operations/prepare.py", line 199, in prepare_linked_requirement
    progress_bar=self.progress_bar
  File "/home/pi/.local/lib/python2.7/site-packages/pip/_internal/download.py", line 1064, in unpack_url
    progress_bar=progress_bar
  File "/home/pi/.local/lib/python2.7/site-packages/pip/_internal/download.py", line 924, in unpack_http_url
    progress_bar)
  File "/home/pi/.local/lib/python2.7/site-packages/pip/_internal/download.py", line 1152, in _download_http_url
    _download_url(resp, link, content_file, hashes, progress_bar)
  File "/home/pi/.local/lib/python2.7/site-packages/pip/_internal/download.py", line 861, in _download_url
    hashes.check_against_chunks(downloaded_chunks)
  File "/home/pi/.local/lib/python2.7/site-packages/pip/_internal/utils/hashes.py", line 75, in check_against_chunks
    for chunk in chunks:
  File "/home/pi/.local/lib/python2.7/site-packages/pip/_internal/download.py", line 829, in written_chunks
    for chunk in chunks:
  File "/home/pi/.local/lib/python2.7/site-packages/pip/_internal/utils/ui.py", line 156, in iter
    for x in it:
  File "/home/pi/.local/lib/python2.7/site-packages/pip/_internal/download.py", line 818, in resp_read
    decode_content=False):
  File "/home/pi/.local/lib/python2.7/site-packages/pip/_vendor/urllib3/response.py", line 531, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "/home/pi/.local/lib/python2.7/site-packages/pip/_vendor/urllib3/response.py", line 496, in read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
  File "/usr/lib/python2.7/contextlib.py", line 35, in __exit__
    self.gen.throw(type, value, traceback)
  File "/home/pi/.local/lib/python2.7/site-packages/pip/_vendor/urllib3/response.py", line 402, in _error_catcher
    raise ReadTimeoutError(self._pool, None, 'Read timed out.')
ReadTimeoutError: HTTPSConnectionPool(host='www.piwheels.org', port=443): Read timed out.

Sorry if I did not show my problems correctly because this is the first time I’m posting here.

 New contributor
  • Ah, let me see. There are many versions of TensorFlow, with different NN models. Please give me the web link to the tutorial or instruction. I can try to reproduce your situation and problem. PS – the error message indicate Python 2.7. So your python env might be corrupted, or you forget to use pip3 (your last pip!) and messed up python 2.7 and 3.7.3 stuff. – tlfong01 Sep 26 at 5:16   
  • You might like to try these (third is out of date), and see if there is any problem. I can try to reproduce your situation.(1) Installing Machine Learning Software TensorFlow on Raspberry Pi – Rishabh Jain 2019may10 circuitdigest.com/microcontroller-projects/… (3) Detect ANY Object with Raspberry Pi and TensorFlow Youtube – 2018dec21 youtube.com/watch?v=zqIBce4LKx8 (2) How to install TensorFlow 1.9 On Rpi – Magpi 2018 raspberrypi.org/magpi/tensorflow-ai-raspberry-pi – tlfong01 Sep 26 at 6:31   
  • I thought your tutorial is out of date, therefore I suggest some more updated references. But the tutorial you provide in your answer is actually from the TF official site, and is more date than mine. So forget what I suggested. I will try to see if I can repeat your situation. Sorry for confusing you. – tlfong01 Sep 26 at 8:51   
  • @Kor please note that you should create an account and use it for all your contributions if you want the site to work properly. I see you tried to edit your own question, but the site didn’t recognize you as the same user. – Dmitry Grigoryev 1 hour ago
  • @tlfong01 From Kor, who lost his/her password to this account: “Thanks for your answer tlfong01, I’ll try that later when I am free. The instructions I follow is from http://www.tensorflow.org/install/pip I didn’t install it in the virtual environment because I don’t see the importance of using a virtual environment in this situation since ML is all that I’m working on in this raspberry pi … I am still trying to solve this issue but still have no substantial update to it.” – goldilocks 1 hour ago

-1

Update 2019 sep29 hkt2241

Apology – I missed something very important. When I got the “memory error” message, my immediate thought was that Tensor Flow is for big Windows/Linux machines with perhaps at least 4GB RAM. So I was thinking of trying again on my PC with 6GB RAM.

It was only when @Dmitry Grigoryev suggested me to increase swap size then I realized that the error message “memory error” is for hackers with IQ > 120+. For newbie with IQ a “little bit” lower, a friendly error message should read:

Sorry, your virtual memory seems too small for TensorFlow to do big things. Perhaps you should increase the swap memory/storage/file a bit and try your luck again.


Update 2019sep26hkt1743

Bad news. I tried but got “memory error“. (My Rpi4B is 2GB version.)

My Rpi4B is 2GB version, free -m shows Total 1939, used 131, free 1525, …


References

(1) How to change Raspberry Pi’s Swapfile Size on Raspbian – Shane Pfaffly 2015feb11

(2) Raspberry Pi – How to increase swap size


Appendices

Appendix A – TensorFlow Installation Error Record

tensor-error 1

.END

  • 2
    Please don’t post pictures of text. Instead paste the text direct into the answer. – Ingo 2 days ago
  • @Ingo, Thanks for your suggestion. Actually I used to cut and paste text here, to make it easy for others to copy and google. From time to time I copy to my penzu journal, and make highlights for easy reading. However this time I captured screen for the following reasons: To let others know that there is no chance for me to make any careless copy/paste errors. I once made newbie mistakes by leaving a space between the “=” in statements, and found it syntax error. The other reason is that I used to copy pasted text to usb stick or ftd server and then pass it to Chinese Win10, … – tlfong01 2 days ago   
  • And Chinese Window from time to time unintentionally switch to Chinese character mode and write Chinese characters which become “big” English or funny character in Rpi.SE. Often I need to reboot Windows to get rid of the funny character mode. That is another reason to paste my text files to Penzu. Anyway, for the next versions of my answer to this question, I will try all three methods as I find appropriate. I know other users just use their camera to copy the image, because they don’t know how to use scrot to do screen capture. I also sometimes use this quick and dirty, when in a hurry. – tlfong01 2 days ago   
  • And when I was a nano newbie, I wrongly thought that nano editing could not cut and past, because ctrl-C, ctrl-V won’t work. If is after some time I found that I can use mouse to select cut and paste operation. If nano did accept ctrl-c, ctrl-v, that would save much newbie’s trouble, … – tlfong01 2 days ago   
  • 1
    ctrl-c, ctrl-v are meaningless in terminal applications. They would work in any GUI editor such as leafpad though. More importantly, I don’t see how MemoryError is a show-stopper. Have you tried to add 2GB of swap? – Dmitry Grigoryev 1 hour ago
  • 1
    @DmitryGrigoryev No, it’s just that ctrl-c triggers a SIGINT which is passed through to the application by the shell. Pretty sure that starts with the kernel doing the capture. Ctrl-v can and is used by TUI applications (e.g., vim), but it does not have a universal meaning. – goldilocks 54 mins ago
  • @Dmitry Grigory, (1) Ha, thanks a lot for the adding 2GB swap advice. Actually I never tried to change the swap space. I am a Windows guy, with 6GB RAM in my PC. I always thought swap space trick is only useful in old days when PC RAM was only 256MB or less . Anyway, I must try that later. (2) Why ctrl-c, ctrl-v are “meaningless”. Are they reserved for other purposes, or for historical reasons? – tlfong01 51 mins ago   
  • Ctrl codes are used to send special characters on keyboards which don’t have dedicated keys for them. ctrl-c sends character 0x03 (which by convention is used to terminate a running command in a shell), ctrl-v sends character 0x16. ctrl-i sends a Tab character, etc. – Dmitry Grigoryev 34 mins ago
  • @goldilocks “ctrl-c triggers a SIGINT” is just a common terminal emulator convention, it certainly has nothing to do with the kernel (not more to do than any other character). vim uses ctrl-c as well. – Dmitry Grigoryev 30 mins ago
  • Yes. so the “real” reason is that ctrl-c has already been assigned to linux to terminate a process. We Windows guys have been using ctrl-C and ctrl-V for cut and paste for decades, and think linux guys unforgivable for “wrongly” assigned ctrl-C to something else. – tlfong01 26 mins ago   Edit   

Categories: Uncategorized

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: