简体   繁体   中英

Integrating TensorFlow with OpenCL using bazel

Description of the problem / feature request / question:

I am trying to use bazel to build TensorFlow Library. It builds fine.

Additional Feature : I would like to add OpenCL code in one of the files of TensorFlow. Added all the required code AND added the following in one of the build files ( tensorflow/core/BUILD ), considering 'opencl' as the root directory of 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", ],

example to reproduce the problem:

By running bazel build //tensorflow/examples/android:tensorflow_demo --fat_apk_cpu=armeabi-v7a --copt="-Ithird_party/opencl/include"

Issues Faced while building :

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

etc

Environment info

Operating System: Ubuntu 17.04

Bazel version (output of bazel info release): release 0.5.1

relevant searching on web?

How to add external header files during bazel/tensorflow build

information or logs or outputs that would be helpful?

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'

I tried linking directly to libOpenCL.so as shown below by referring https://bazel.build/versions/master/docs/tutorial/cpp.html#adding-dependencies-on-precompiled-libraries , but still same issue

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

Please help me in resolving the issues

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM