tensorflow-on-raspberry-pi
tensorflow-on-raspberry-pi copied to clipboard
Un-sudo the guide
Context
Right now, the project relies on having the user sudo
pretty much everything: pip
installs, compiling Bazel, etc. However, it would be best if this project could practice the safest security practices possible, which would mean removing as many sudo
commands as possible. A number of users have suggested making changes along these lines:
-
Suggestion to use
--user
flag forpip install
instead ofsudo
-
Comment about not needing
sudo
when running./compile.sh
for Bazel
I tried altering the instructions to use pip install --user
, instead of sudo pip install
, but unfortunately this caused bugs for many users, and these changes was reverted:
-
tensorboard
command doesn't work when installing with--user
flag -
Import errors for TensorFlow when using
--user
flag
Current status
So far, I've kept the README and GUIDE as-is because they work (generally). Right now, I'm prioritizing functionality over safety (which is a point worth arguing over), but the hope is to have our cake and eat it too.
The hope is to remove sudo
from every step that involves running a Python or bash script. This currently includes the following commands:
README.md
sudo pip install tensorflow-1.0.1-cp27-none-linux_armv7l.whl
sudo pip3 install tensorflow-1.0.1-cp34-cp34m-linux_armv7l.whl
sudo pip2 install tensorflow-1.0.1-cp27-none-linux_armv7l.whl
sudo pip uninstall mock
sudo pip install mock
sudo pip3 uninstall mock
sudo pip3 install mock
GUIDE.md:
sudo pip install wheel
sudo pip3 install wheel
sudo ./compile.sh
sudo pip install /tmp/tensorflow_pkg/tensorflow-1.0.1-cp27-none-linux_armv7l.whl
Testing
Making sure that these changes work properly requires some form of testing. Creating a testing protocol has been on the backburner for a while (#32), but it's the best way to make sure that the created binaries actually work correctly (as opposed to just appearing to work correctly on first glance). I still don't have the time to focus on this, but it's important to mention.
On Virtualenv
I think the "best" solution for users wanting to install the TensorFlow binaries safely is to have them use a Virtualenv. That said, I don't want to include creating a Virtualenv as part of the build instructions. Unfortunately, this is more about my predictions about issues getting raised along the lines of the format:
Issue: "No module named tensorflow"
Answer: Did you `source /envs/tensorflow/bin/activate`?
This is definitely more about my personal preferences as the maintainer than it is about doing what's "optimal". The thing is, I just don't have the time to help users debug these sorts of problems, so I'm going to avoid adding additional issue-causing surfaces.
As a compromise, I think adding links to the official TensorFlow guide on installing with Virtualenv to the README should be enough to provide users with the resources to figure it out on their own.
I recieved an error when accidently trying to ./compile.sh
without sudo
.. system is
Ubuntu Mate 16.x Raspberry Pi 2
cannot create regular file 'output/bazel': Permission denied
ERROR: could not copy '/tmp/bazel_hashhash/out/execroot/bazel/bazel-out/local-opt/bin/src/bazel' to 'output/bazel'