Building TensorFlow from source with GPU support on Ubuntu 16.04

Basically it is a case of following the instructions here. However, I hit a few problems along the way. These are described in some issues in the GitHub repo (specifically 1066 and 3431) but it’s worth documenting the required changes here.

There are three lines that need to be added to the CROSSTOOL file that can be found at:

<path to tensorflow>/third_party/gpus/crosstool

After line 54 add:

cxx_flag:"-D_MWAITXINTRIN_H_INCLUDED"
cxx_flag:"-D_FORCE_INLINES"

After line 64 add:

cxx_builtin_include_directory: "/usr/local/cuda-7.5/include"

Obviously change the CUDA version to whatever is being used.

To keep Bazel happy, I also had to set JAVA_HOME to the explicit path:

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

This may have been something odd with this specific machine however.

One additional thing is required to use GPU support with Python scripts:

sudo ldconfig /usr/local/cuda/lib64
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s