Installing tensorflow
This is another quick post on installation difficulties and how to alleviate them. We’re looking at TensorFlow as an ML solution for many of the things we are exploring with vg. It’s awesome that it’s free and open-source, and the community is growing by the day. However, installation isn’t always a breeze.
I first tried to install tensorflow using pip a la Google’s instructions (I already had python-dev
and pip
on my system):
sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.7.0-py2-none-linux_x86_64.whl
This fails with an error saying that the wheel isn’t supported on my platform. There’s a simple workaround for this on StackOverflow, but it still wouldn’t work for me. After updating pip, I tried the local install method reference in the TensorFlow docs:
wget https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.7.0-py2-none-linux_x86_64.whl
sudo pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.7.0-py2-none-linux_x86_64.whl
This seemed to work, but then when I cracked open python and tried import tensorflow as tf
, I got another error, even though I’m on Ubuntu 14.04 and not Mac OS.
The solution was to update my protobuf to the bleeding edge.
git clone --recursive https://github.com/google/protobuf.git
cd protobuf/
./autogen.sh
./configure --prefix=/usr
make -j 4
make check ## All tests passed here
sudo make install
sudo ldconfig ## Places new libs on LD_LIBRARY_PATH
At this point, I had installed the C++ version of protobuf and could compile things with protoc
, but I still needed the python
bindings.
## Still in protobuf dir
cd python/
python setup.py build
python setup.py test ## Fails ~ 2% of all tests
python setup.py install
And only then I could test TensorFlow and run the examples. If you’re installing locally, all the instructions should be about the same but you’ll need to use ./configure --prefix=/your/install/dir
and ensure that you add the relevant directories to the LD_LIBRARY_PATH
and LD_INCLUDE_PATH
. Hopefully the next post is on doing something neat with TensorFlow now that I’ve got it installed!