Tensorflow setup - Second trial

After my terrible failure trying to setup tensorflow yesterday, I decided I should take the “not that complicated” road, and install the required version of CUDA and cudNN instead of trying to build Tensorflow from sources.

So, as mentioned in that previous post on this topic, from the webpage https://www.tensorflow.org/install/source#tested_build_configurations we can see that tensorflow v1.12.0 should be used with CUDA v9 and cudNN v7.

Once the packages are downloaded, the first step is to remove the previous installation of CUDA 10.0, on windows, this means removing the packages:

  • NVIDIA CUDA Development 10.0
  • NVIDIA CUDA Documentation 10.0
  • NVIDIA CUDA Runtime 10.0
  • NVIDIA CUDA Samples 10.0
  • NVIDIA CUDA Visual Studio Integration 10.0
In fact we could probably keep both CUDA 9.x and CUDA 10.0 installed on the same computer, but since I don't have a clear need for version v10.0, I prefer to remove it.
Actually, when they say CUDA version 9, they really mean version 9.0, and not 9.2 ⇒ I just tried with CUDA v9.2, and again tensorflow is not starting because of library loading errors :-(.

Once CUDA v9.0 and cudNN v7.4.2 are properly installed and available on the path, we can try to load tensorflow again from a simple python script, and this time we don't have the library loading issue anymore. But of course, there is another issue! Would have been too easy otherwise:

>>> import tensorflow
2018-12-29 17:00:37.884706: F tensorflow/python/lib/core/bfloat16.cc:675] Check failed: PyBfloat16_Type.tp_base != nullptr

⇒ From what I read it seems this might be related to a numpy version mismatch. So let's try to upgrade numpy:

pip install --upgrade numpy

⇒ And Yes! This did the trick! :-) Importing the tensorflow module in python is now finally working on Windows.

Now also trying the same process on my ubuntu 14.04 server… and OK, this is working too once CUDA 9.0 is installed.

As a personal side note: for now I need to manually call nv_py_setup_paths before starting a python shell to ensure the CUDA libraries are found on Linux.

As a final test, we will now try a second sanity check from inside a Jupyter env on Windows:

import tensorflow as tf

session = tf.Session()
a = tf.constant(2)
b = tf.constant(3)
multiply = tf.multiply(a, b)
session.run(multiply)

⇒ The code above will print the resulting value 6 as expected. So we can conclude here that tensorflow is properly installed and ready for usage. Next time we will finally start experimenting on networks on the MNIST dataset!