Jun 1, 2019
A recent question from the Something Awful Forums:
Can I run TensorFlow on a Raspberry Pi Zero?
The answer? You can, but it’s a bad idea.
|System||Package||Install Time||Test Time|
|Raspberry Pi Zero W||Virtualenv/Pip||>1 hour||40 seconds|
|Raspberry Pi 3 Model B+||Virtualenv/Pip||10 minutes||10 seconds|
|AMD ThreadRipper 1950X (KVM VM, 8 cores)||Docker image||2 minutes||1.8 seconds|
Below are the steps I took to install TensorFlow on a Raspberry Pi Zero W. Note: you have to use Virtualenv to install TensorFlow in Raspbian. If you try to install TensorFlow directly with Pip, the installation will bomb out with an error.
Raspberry Pi Installation Steps:
# install system pip, numpy dependencies, and virtualenv sudo apt-get install python3-pip python3-dev libatlas-base-dev virtualenv # at this point i tried to install tensorflow directly via pip, which does NOT work # sudo pip3 install --upgrade tensorflow # created virtualenv environment instead virtualenv --system-site-packages -p python3 ./venv # activate virtual environment "venv" # note: after this command your shell prompt will be prefixed with "(venv) " source ./venv/bin/activate # install tensorflow (i also installed keras here, because I use it for other stuff) # note: this step takes a comically long time (>1 hour) pip install tensorflow keras
Test Results (Raspberry Pi Zero W):
(venv) pabs@zero:~> time python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))" ... tf.Tensor(1533.9042, shape=(), dtype=float32) real 0m40.802s user 0m38.283s sys 0m1.150s
Test Results (Raspberry Pi 3 Model B+):
(venv) pabs@peach:~> time python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))" ... tf.Tensor(800.62, shape=(), dtype=float32) real 0m9.408s user 0m9.227s sys 0m0.360s
pabs@hive:~> time docker run --rm -it tensorflow/tensorflow:latest-py3 python3 -c \ "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))" ... tf.Tensor(-173.73222, shape=(), dtype=float32) real 0m1.745s user 0m0.032s sys 0m0.016s
virsh capabilitieson the host to get a list of host CPU capabilities, then
virsh editto manually add the necessary CPU flags as
<feature>tags under the
For an AMD Threadripper 1950X, the resulting
looks like this:
<cpu mode='host-model'> <model fallback='allow'/> <feature policy='require' name='sse4.1'/> <feature policy='require' name='sse4.2'/> <feature policy='require' name='avx'/> <feature policy='require' name='f16c'/> <feature policy='require' name='avx2'/> <feature policy='require' name='ssse3'/> </cpu>
pabs@hive:~> time docker run --rm -it tensorflow/tensorflow:latest-py3 \ python3 -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))" 2019-04-06 12:25:16.576095: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA 2019-04-06 12:25:16.627588: I tensorflow/core/platform/profile_utils/cpu_utils.c c:94] CPU Frequency: 3393620000 Hz 2019-04-06 12:25:16.629909: I tensorflow/compiler/xla/service/service.cc:150] XL A service 0x395bf00 executing computations on platform Host. Devices: 2019-04-06 12:25:16.629968: I tensorflow/compiler/xla/service/service.cc:158] StreamExecutor device (0): <undefined>, <undefined> tf.Tensor(-95.5094, shape=(), dtype=float32) real 0m1.780s user 0m0.024s sys 0m0.012s
This weekend I put together a simple password strength tester. You can try it out here.
Took delivery on my Tesla Model 3 (LR AWD) one week ago today.
So far it’s great!
I’ve been taking notes on everything, and I will share them eventually.
I think 10 years is enough of a break.
Please excuse the cobwebs for the next few weeks…
Truncate articles in RSS feeds are incredibly anno...
This release fixes a small bug with the
--daemon option when the controlling terminal is closed, and removes the advertising clause from the license.
Joggle is available via RubyGems (
gem install joggle) or you can download it directly from the URLs below.
I just released version 0.2.2 of ZipStream-PHP. ZipStream-PHP is a library that allows you to generate and stream zip files on the fly without writing an intermediate temporary file to the disk. It works with existing files and dynamically generated content, and has been used to dynamically generate zip files hundreds of megabytes in size.
This release of ZipStream-PHP updates the license to remove the advertising clause and fixes a few errors in the documentation. There are no code changes; if you're happy with 0.2.1 there is no immediate reason to upgrade.
I just released version 0.1.3 of Wirble. Wirble is a set of enhancements for Irb (the interactive Ruby shell), including tab-completion, history, and, most notably, colorized results.
This release adds Ruby 1.9 support and removes a couple of warnings. I've also added better support for non-RubyGems installations (via
setup.rb) and removed the advertising clause from the license.
You can install Wirble via RubyGems or download it directly from one of the URLs below. Enjoy...