Skip to content

Instantly share code, notes, and snippets.

@petewarden
Last active April 4, 2018 04:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save petewarden/6aa9650fe72d88889d24efd76598f8cb to your computer and use it in GitHub Desktop.
Save petewarden/6aa9650fe72d88889d24efd76598f8cb to your computer and use it in GitHub Desktop.
git clone https://github.com/tensorflow/tensorflow tensorflow
cd tensorflow
docker build -t "tf-pi" -f tensorflow/tools/ci_build/Dockerfile.cpu tensorflow/tools/ci_build/
docker run -it tf-pi
# Commands after this are run on the Docker instance.
dpkg --add-architecture armhf
echo 'deb [arch=armhf] http://ports.ubuntu.com/ trusty main restricted universe multiverse' >> /etc/apt/sources.list.d/armhf.list
echo 'deb [arch=armhf] http://ports.ubuntu.com/ trusty-updates main restricted universe multiverse' >> /etc/apt/sources.list.d/armhf.list
echo 'deb [arch=armhf] http://ports.ubuntu.com/ trusty-security main restricted universe multiverse' >> /etc/apt/sources.list.d/armhf.list
echo 'deb [arch=armhf] http://ports.ubuntu.com/ trusty-backports main restricted universe multiverse' >> /etc/apt/sources.list.d/armhf.list
sed -i 's#deb http://archive.ubuntu.com/ubuntu/#deb [arch=amd64] http://archive.ubuntu.com/ubuntu/#g' /etc/apt/sources.list
apt-get update
apt-get install -y libpython-all-dev:armhf
echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
apt-get update
rm -rf /usr/local/bin/bazel
apt-get install -y bazel python python-numpy python-dev python-pip
git clone https://github.com/tensorflow/tensorflow tensorflow
cd tensorflow
third_party/toolchains/cpus/arm/build_raspberry_pi.sh
# On the host OS (change the path to the actual temp directory shown by the build output).
docker cp `docker ps -alq`:/tmp/tmp.smXLh20Qhj/tensorflow-1.3.0rc0-cp27-none-any.whl ~/Downloads/
@ebrevdo
Copy link

ebrevdo commented Jul 23, 2017

I think the second to last command is not necessary, but the last command needs to know the true tmpdir

@petewarden
Copy link
Author

You're right, I just had it because I was having to restart the bazel build manually after hitting RAM limits and the OOM killer, so the rest of the script was being skipped. I've updated it.

@petewarden
Copy link
Author

You'll also need to apply this patch to the source to get NEON Pi 2/3 builds working, until the Eigen version is updated:
lissyx/tensorflow@f7def94

@mattfeury
Copy link

tried this guy to build a PI_ONE wheel. successfully generated and successfully installed, but on python import i'm seeing

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 63, in <module>
    from tensorflow.python.framework.framework_lib import *
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/framework_lib.py", line 102, in <module>
    from tensorflow.python.framework.importer import import_graph_def
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/importer.py", line 30, in <module>
    from tensorflow.python.framework import function
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/function.py", line 34, in <module>
    from tensorflow.python.ops import variable_scope as vs
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.py", line 191, in <module>
    """
AttributeError: 'int' object attribute '__doc__' is read-only

i previously saw an import error ImportError: No module named enum but was able to move past it with a pip install

@mattfeury
Copy link

mattfeury commented Aug 19, 2017

was able to comment that __doc__ line out and everything is running fine now. so slowww tho, but that's another matter entirely

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment