TensorFlow in Python3
TensorFlow is an Open Source library that Google has released earlier this month. It allows to, in a simple manner, arrange processing and training flows, with elements like neural networks, and even implement new operations over it's architecture (tutorial and examples).
This library is written in C++, but the architecture, the data to be managed and the operations are declared in Python. This is great, as it yields a great performance without having to deal with Segmentation Faults, but if you were expecting to use Python3 for this... you may have to wait a while, at this moment it's not supported [tensorflow GitHub issue #1], but it's support is planned.
Meanwhile, in this repo, in the python3 branch, you have a way to use it... it's not completely updated and there's things to tune, like checkpoints. Also, you'd have to build it manually (there's no prebuild pip package), but we'll see that can be done easily.
Bazel
Well, it turns out that in order to build TensorFlow, it's not enough with make
,
but it's made to be built with bazel.
Install this is pretty easy, the instructions are in bazel.io.
Once the dependencies are installed, Bazel has it's own installer, that can be
launched piping a curl
of their script to a shell (ugh...) or cloning a repo,
like the we say says, for this we only have to do this
1 2 3 |
|
This will generate a Bazel binary in bazel-bin/src/bazel
, that we can move
to whatever $PATH we want. We also have a file to help autocomplete in
scripts/bazel-complete-template.bash
. We can add it to .bashrc
with
a line like this
1 |
|
Virtual environment
Once we have Bazel ready, we have to prepare the virtual environment where we'll host the packages which TensorFlow depends upon. For this we only have to
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
TensorFlow
When the environment is completely ready, it only remains to generate the pip, package, but wait a moment: it seems that with GCC-5 the process uses too much RAM, so we'll have to avoid paralelizing it so it doesn't clogs the whole PC. So if the GCC version is inferior to 5, the commands would be
1 2 |
|
In order to (in GCC 5), limit the compiler concurrency, we'll do this:
1 2 |
|
Once this is done, we can generate the package with
1 |
|
The second argument specifies where the compiled package will be dropped (/tmp/tensorflow_pkg
),
we can use whichever we want (also, delete it once is installed).
After this, it only remains to install the generated package
1 |
|
And it's done, we can use the library
1 2 3 4 5 6 |
|