I am trying to add external header file (like OpenCL header file) for some experimentation for tensorflow. I tried to add this into BUILD file under tensorflow/core/BUILD file:
# This includes implementations of all kernels built into TensorFlow.
cc_library(
name = "all_kernels",
visibility = ["//visibility:public"],
copts = tf_copts() + ["-Ithird_party/include"], <==== this is the line I added
I have also created a softlink in this directory to the location of these header files from OpenCL driver (under tensorflow/third_party) too (like ln -s /opt/opencl/ ) but it still complains that it has not found that header file.
If I add external header file directly (like /opt/opencl/CL/) it complains that external files cannot be included (or some such thing).
I do not have root password to copy these header files into /usr/include/ too.
Can someone explain how exactly to do external header files into tensorflow for building?
Thanks for any quick help.
I've faced with the similar problem when I built TensorFlow with Intel MKL and had to add MKL headers. My solution is the following:
Create symlink to your headers into third_party folder, like:
<your tensorflow folder>/third_party/opencl/include -> /opt/OpenCL/include
with command:
ln -s /opt/OpenCL/include <your tensorflow folder>/third_party/opencl
Create simple BUILD file into <your tensorflow folder>/third_party/opencl
folder:
cc_library(
name = "opencl",
hdrs = glob(["include/CL/*.h"]),
visibility = ["//visibility:public"],
)
Add deps into target library:
cc_library(
name = "all_kernels",
visibility = ["//visibility:public"],
copts = tf_copts() + ["-Ithird_party/opencl/include"],
deps = [
"//third_party/opencl",
...
],
)
Don't forget to add compiler options either into target library as shown above or just as a flag to bazel:
bazel build --copt="-Ithird_party/opencl/include" ...