Skip to content

Docker container for the Raspberry Pi containing Tensorflow and Jupyter

License

Notifications You must be signed in to change notification settings

romilly/rpi-docker-tensorflow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rpi-docker-tensorflow

Warning:

This is definitely not production code, but it runs on my machine(tm).

It requires the latest nightly build of Docker for the Pi.

Background:

I originally started this project to create a simple way for Pi owners to experiment with TensorFlow.

At the time, neither Docker nor TensorFlow were officially supported on the Pi.

More recently, this project has been dormant, because

  1. TensorFlow and Docker have officially supported Raspbian for a while, and
  2. While TensorFlow will run in a Docker container with Jupyter, the limited memory of the Pi 3B+ meant that you couldn't do much with it.

This has changed with the 4 GB model of the Pi 4B.

I'm now attempting an experimental build for Raspbian buster that runs on a Raspberry Pi 4.

I am testing the build using Raspbian/buster and a 16 GB SD card on a Raspberry Pi model 4B with 4 GB of RAM.

The script builds a container based on Katsuya Hyodo's build of TensorFlow 1.14 for the Raspberry Pi, with TensorFlow Lite enabled.

The docker image contains TensorFlow, Jupyter and a TensorFlow notebook copied from the official Google docker TensorFlow build.

The original build relied heavily on the work of resin.io, the Docker team, Sam Abrahams and the Google TensorFlow team. Sources are listed below.

This is not an official TensorFlow port, so don't ask for or expect support from the TensorFlow team.

Build instructions

  1. Install Docker nighly build on your Raspberry Pi.
  2. curl -fsSL get.docker.com | CHANNEL=nightly sh
  3. sudo usermod -aG docker pi
  4. log out, then log back in again for the change to take effect
  5. sudo systemctl start docker
  6. Clone this repository into a directory of your choice
  7. git clone https://github.com/romilly/rpi-docker-tensorflow.git
  8. Build the image
  9. cd rpi-docker-tensorflow/build-tensor-pi/
  10. docker build -t='yourName/rpi-docker-tensorflow' .

Running the image

This run instruction expects a directory called myNotebooks within your home directory.

If you save an IPython notebook to the myNotebooks sub-directory while running your container, it will get saved to the myNotebooks directory on your Pi.

Notebooks saved to that directory will be persistent - in other words, they will still be there when the container is stopped and restarted.

docker run -it -p 8888:8888 -v ~/myNotebooks:/notebooks/myNotebooks yourName/rpi-docker-tensorflow

You can probably ignore the warnings about the insecurity of the IPython server configuration so long as you do not store any sensitive data or code in your notebooks.

Connecting to the notebooks

Open a browser on http://raspberrypi:8888 where raspberrypi is the hostname of the Pi on which the docker image is running, or on http://localhost:8888 on the Pi itself.

You should see a screen like this:

aaand you're away to the races!

I'll blog more info about this shortly, and will commit the image to docker central once it's working.

Stopping the image

In the terminal session where you ran the container, type Ctr-C twice in quick succession. The container will stop.

Sources

  1. Docker: http://blog.alexellis.io/getting-started-with-docker-on-raspberry-pi/
  2. Katsuya Hyodo's build of TensorFlow 1.14 for
  3. Notebook from The Tensorflow website

About

Docker container for the Raspberry Pi containing Tensorflow and Jupyter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published