Compile OpenCl support on tensorflow in ubuntu 16.04

Hi everyone, i just try to compile opencl support on tensflow. let’s do it

Step:

1.  Download computecpp(compute++) from https://www.codeplay.com/products/computesuite/computecpp

2.  Extract ComputeCpp-CE-0.1.1-Ubuntu.14.04-64bit.tar.gz to /usr/local

$ tar xvf ComputeCpp-CE-0.1.1-Ubuntu.14.04-64bit.tar.gz

$ sudo mv ComputeCpp-CE-0.1.1-Linux /usr/local/computecpp

3.  After following this official tensorflow build from source  instruction at this –>  https://www.tensorflow.org/get_started/os_setup#installing_from_sources
[Configure]

Please specify the location of python. [Default is /usr/bin/python]:
Do you wish to build TensorFlow with Google Cloud Platform support? [y/N]
No Google Cloud Platform support will be enabled for TensorFlow

Do you wish to build TensorFlow with Hadoop File System support? [y/N]
No Hadoop File System support will be enabled for TensorFlow
Found possible Python library paths:
/usr/local/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages
Please input the desired Python library path to use. Default is [/usr/local/lib/python2.7/dist-packages]

Using python library path: /usr/local/lib/python2.7/dist-packages
Do you wish to build TensorFlow with OpenCL support? [y/N] y
OpenCL support will be enabled for TensorFlow
Do you wish to build TensorFlow with CUDA support? [y/N]
No CUDA support will be enabled for TensorFlow
Please specify which C++ compiler should be used as the host C++ compiler. [Default is /usr/bin/g++]:
Please specify which C compiler should be used as the host C compiler. [Default is /usr/bin/gcc]:
Please specify the location where ComputeCpp for SYCL 1.2 is installed. [Default is /usr/local/computecpp]:
Extracting Bazel installation…

4. at “Create the pip package and install” section change # To build with GPU support:

–  from

bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package

– to

bazel build -c opt --config=sycl //tensorflow/tools/pip_package:build_pip_package

 

that’s it!

PS:  if you get any an error continue to repeat and repeat compile&configure until minimal error…it’s stuck at 3 ERROR: but you can try to install and test in python

$ bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

sudo bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
Sun Dec 18 13:03:42 ICT 2016 : === Using tmpdir: /tmp/tmp.T4DuTYdKvm
/bazel-bin/tensorflow/tools/pip_package/build_pip_package.runfiles ~/tensorflow/src/tensorflow
/tmp/tmp.T4DuTYdKvm ~/tensorflow/src/tensorflow
Sun Dec 18 13:03:46 ICT 2016 : === Building wheel
Sun Dec 18 13:07:37 ICT 2016 : === Output wheel file is in: /tmp/tensorflow_pkg
$ ls /tmp/tensorflow_pkg
tensorflow-0.12.0rc1-cp27-cp27mu-linux_x86_64.whl
$ sudo pip install /tmp/tensorflow_pkg/tensorflow-0.12.0rc1-cp27-cp27mu-linux_x86_64.whl

Screenshot: