Setting Up TensorFlow On Julia

12 Nov 2017


Note - The instructions are chiefly for Linux (Ubuntu) users. Apologies to others. Also, beware that the steps for a GPU enabled version of TensorFlow is fraught with risks, thanks to the breakage prone shenanigans of Nvidia drivers on Ubuntu/Linux.

First, a few definitions.

What is TensorFlow?
TensorFlow is an open-source software library for dataflow programming across a range of tasks. It is a symbolic math library, and is also used for machine learning applications such as neural networks.

What is TensorFlow,jl?
A wrapper around TensorFlow in the Julia language. Also, some advantages of this over Python.

Now, let’s get everything set up.

For CPU version of TensorFlow

That should do it. Try typing using TensorFlow in the REPL to check if the package is running perfectly. Refer to the link ahead in case you see issues from the ccall or python interop.

For GPU-enabled version of TensorFlow

The Nvidia Driver

Right, that was the simple route for CPU usage. You can optimise CPU usage by building TensorFlow from source. That’s a bit outside the scope of a simple setup though.
Now if you want to use the shiny Nvidia graphics card i.e use TensorFlow with GPU enabled, there’s going to be a bit of pain. In the range of possible scenarios, you could faces problems ranging from lower screen resolution to a flickering screen to a complete black screen.

The tricky thing is there’s no one-shot cure to this problem. Here’s the standard method -
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install nvidia-current
sudo reboot

You’ll be asked to enter a password to disable the secure boot after login. Be careful to not forget the password, in case of problems it can come handy.
If you do face problems and are not sure what to do, don’t panic. Try to access the TTY and type in the following command to get back to how things were before -
sudo apt-get purge nvidia-current
sudo reboot

As I said, different people with different setups + hardware + driver version will face different problems.
The thing that worked for me personally (after hours of successive install and purge cycles) was to install the drivers not from the command line but from the GUI of the Additional Drivers application.
I simply selected the version(381) I wanted (select the circle on the left), which it automatically installed. Then, Reboot -> disable secure boot -> Voila!
Only thing I can say is, good luck with this step.

CUDA and cuDNN

Final step