使用 bazel 将 TensorFlow 与 OpenCL 集成

Integrating TensorFlow with OpenCL using bazel

问题描述/功能请求/问题:

我正在尝试使用 bazel 构建 TensorFlow 库。它构建良好。

附加功能: 我想在 TensorFlow 的一个文件中添加 OpenCL 代码。添加了所有必需的代码 并在其中一个构建文件 (tensorflow/core/BUILD) 中添加了以下内容,将 'opencl' 视为 opencl 的根目录。

cc_library( name = "opencl", hdrs=glob(["opencl/include/CL/*h"]),
visibility =["//visibility:public"], )

cc_library( name="all_kernels" , visibility= ["//visibility:public"],
copts=tf_copts() + ["-Ithird_party/opencl/include"], deps= [
"//third_party/opencl", ],

重现问题的示例:

来自 运行 bazel 构建 //tensorflow/examples/android:tensorflow_demo --fat_apk_cpu=armeabi-v7a --copt="-Ithird_party/opencl/include"

构建时遇到的问题:

error: undefined reference to 'clEnqueueReadBuffer'
error: undefined reference to 'clReleaseMemObject'
error: undefined reference to 'clReleaseMemObject'

等等

环境信息

操作系统:Ubuntu17.04

Bazel 版本(bazel 信息发布的输出):发布 0.5.1

在网络上搜索相关内容?

How to add external header files during bazel/tensorflow build

有用的信息或日志或输出?

bazel-out/android-arm-linux-androideabi-4.9-v7a-gnu-libstdcpp-fastbuild/bin/tensorflow/core/kernels/libandroid_tensorflow_kernels.lo(conv_ops.o):conv_ops.cc:function
matrixMul(float*, float*, int, int, int, int, int, int): error:
undefined reference to 'clGetPlatformIDs'

我尝试通过引用 https://bazel.build/versions/master/docs/tutorial/cpp.html#adding-dependencies-on-precompiled-libraries 直接链接到 libOpenCL.so,如下所示 , 但仍然是同样的问题

cc_library( name = "opencl", srcs = glob(["lib/x86_64/.so"]), hdrs =
glob(["include/CL/.h"]), visibility = ["//visibility:public"], )

请帮我解决问题

libOpenCL.so 在终端中显示为红色,这意味着它已存档,替换文件并解决问题