【问题标题】:Integrating TensorFlow with OpenCL using bazel使用 bazel 将 TensorFlow 与 OpenCL 集成
【发布时间】:2017-06-10 17:51:46
【问题描述】:

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

我正在尝试使用 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'

环境信息

操作系统:Ubuntu 17.04

Bazel 版本(bazel info release 的输出):release 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"], )

请帮我解决问题

【问题讨论】:

    标签: tensorflow opencl bazel


    【解决方案1】:

    终端中的 libOpenCL.so 是红色的,这意味着它已被存档,替换文件并解决了问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多