How to Install Tensorflow 2 on a Raspberry Pi

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video i'm going to show you how to download tensorflow 2 onto your raspberry pi for all your machine learning needs you can't just pip install tensorflow so we're going to install it through a community hosted wheel now we got to find the right wheel file and to do that let's look at the architecture of your raspberry pi here i'm ssh into my raspberry pi maybe you access your raspberry pi as a desktop and so if that's the case open a terminal we just need to get to the terminal of the raspberry pi all right architecture you name dash m i have the arm v7 architecture and then next command here all these commands are down in the description by the way you can follow along there cat slash etc os dash release and basically this is looking to see if we have a recent operating system in case you don't i would recommend you do sudo apt update and then sudo app full upgrade to get a more recent operating system and also i've only tested this with raspberry pi os if you're running ubuntu or some other os on your raspberry pi i can't guarantee this will work but it's worth a shot and then finally let's check our python version python-v and all raspberry pi os comes with python installed so if you're running python you want python3 you might need to do python 3 v depending but let's get python3 i have python37 here and now i'm going to follow this link right here and this is a bunch of shell commands to help us download the right version of tensorflow we've got all these tensorflow ones tensorflow twos but basically i'm looking for one that's python three seven right here and then also rather than the arch 64 i want the arm v7 architecture so i'm going to pick this one right here and it also has a numpy specification and this is helpful later on just note that if you look at the later versions 3939 for tensorflow 2.7 the only options are arch 64. if it's the case that you have python 39 and only arm v7 running on your raspberry pi that means you have a 32-bit operating system and it's not supported for the tensorflow 2.7 so i would recommend you downgrade your python and you can do that with a command like pi m i have a tutorial for that here feel free to watch that if you need to downgrade your python and then we can get a different version of tensorflow that's compatible with your architecture okay so which one did i pick i pick this one and i'm going to open that and we'll come back to this later back to the instructions in the terminal okay let's make our project directory make dur project i'm just going to call this folder project and change directories into project great we're going to do a virtual environment in case you don't have virtual environment installed let's install that first i already have it installed and now let's create a virtual environment python dash m virtual m and i would recommend doing virtual environments for things like tensorflow because package versioning matters a lot great now let's activate our environment source and bin activate now let's install some packages these are system-wide packages this big list right here and then some python packages we don't actually need to install these let's go back to this internet browser the three dots here we want to view raw and copy that url ctrl c to copy okay back to my instructions in terminal and we're just going to download that file using the command w get and then that url great and now we want to make this into an executable and just to show you ls to lisk that lists the items in the directory we have that shell file downloaded now okay pseudo ch mod plus x and then that file so if you just type the name of the file down and start typing it and press tab it should autofill okay so now we're allowed to run that as an executable file and so we're going to just run it so period forward slash and then down and tab to auto complete run and this is downloading the appropriate wheel file for our tensorflow installation okay now if we ls to list oops or we got to go over here all right all done now if we list the items in our directory we see we now that have this whl wheel file at the bottom and this is how we're going to install tensorflow so just in case let's uninstall any other versions of tensorflow you might have because these will be conflicting otherwise sudo pip uninstall tensorflow and then pip uninstall tensorflow great and i didn't have it installed that's a good sign and now ls to list the item in the directory i'm going to install off of that wheel file so pip install i'm just gonna try start typing tens and then tab to auto complete okay all installed now let's restart the terminal with the command exec dollar sign shell in all caps this gets us out of our virtual environment so let's go back into it source not on all caps source m bin activate moment of truth let's see if it worked python to get into a python interpreter import tensorflow okay this is good so this error will take care of it in a sec but let's just do tensorflow dot version and then two underscores on each side of version and we got 2.5.0 great quit to get out of the python interpreter and so what this warning is saying is that we have a mismatched version of hd f5 with our h5 pi installation so we just need to reinstall h5 pi with the right version of hdf5 so that's number nine here in the instructions if you're following along i need to add pip uninstall uninstall h5 pi so we're going to run that first remove our current version of h5 pi and now i have the version all written out here okay and now i'm going to replace desired version of hdf5 with here it says h5pi is running against hdf5 1.10.6 but it was built with 1.10.4 so here we're going to put 1.10.6 enter and just so you know that does take a little while now if we go back into our python interpreter python and then import tensorflow no error good import let's do tensorflow version to see if it actually works and it does there we go that's how we install tensorflow on our raspberry pi specifically tensorflow 2.5 on a raspberry pi if you have any questions or get stuck anywhere feel free to leave a comment and also check out my channel because i have some other raspberry pi tutorials that you might be interested in thanks for watching
Info
Channel: Sam Westby Tech
Views: 26,150
Rating: undefined out of 5
Keywords: easy install tensorflow, install tensorflow on raspberry pi, tensorflow raspberry pi, raspberry pi tutorials, ai on raspberry pi, install tensorflow on a raspberry pi, install tensorflow 2 on a raspberry pi, install tensorflow on a raspberry pi 4
Id: QLZWQlg-Pk0
Channel Id: undefined
Length: 8min 45sec (525 seconds)
Published: Fri Jan 21 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.