Integrating TensorFlow with OpenCL using bazel - tensorflow

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

The libOpenCL.so was red in color in terminal, which meant it was archived, replaced the file and issue is resolved

Related

Yocto - Can't build library for host SDK

I've made a custom recipe for a third-party library.
It contains:
BBCLASSEXTEND =+ "native nativesdk"
The recipe builds a static library, depends on virtual/kernel and copies some headers - relatively simple.
I'm trying to install this into the host SDK for cross-compilation, but I'm having some issues.
When I try adding:
TOOLCHAIN_HOST_TASK_append = " nativesdk-<recipe>"
... to local.conf and run bitbake core-image-weston -c populate_sdk, BitBake completes, but the headers and library are absent from the host SDK (for my host's architecture).
When I try adding:
TOOLCHAIN_HOST_TASK_append = " <package>-staticdev"
... I get the following error:
package <package>-staticdev-1.11.0-r0.aarch64 does not have a compatible architecture
Any help would be appreciated.
As you don't need native part of recipe to run something on host (build machine) but target part, you should add the following line to add it to SDK:
TOOLCHAIN_TARGET_TASK_append = " <package>-staticdev <package>-dev"

PixiJS for Haxe won't import - Type Not Found error in IntelliJ

I'm trying to run the most basic PixiJS for Haxe sample program, but IntelliJ gives a Type Not Found error.
The failing code:
package ;
import pixi.core.Application;
The error message:
Main.hx:3: characters 7-28 : Type not found : pixi.core.Application
I think the issue is PixiJS-specific, as when I follow the same install-and-import steps for other Haxe modules (eg flambe, flixel) they behave as expected. I've tried with both 4.7.1 and 4.5.5, and as both global and project-specific libraries (separately).
(I hybridized several screenshots to save space)
When running from the console, using:
> haxe -main Main -lib pixijs -js output.js
Everything seems to compile (running the compiled code results in a PIXI is not defined error which is a seperate issue).
UPDATE 1, how I'm adding the dependency:
After executing haxelib install pixijs, I follow these steps:
UDPATE 2, the config being run:
If you can't get it working in the dependencies section you could try adding the haxelibs pixijs externs src/ folder as an additional sources root in Project Structure -> Modules -> (module name) -> Sources. That's how it worked for me:

Bazel quits before building new op without error?

I was building a new Tensorflow op with external libraries yesterday and getting errors. Today when I ran the same code for some reason I ended up with this output instead:
(vent)user#server:/dir/tensorflow/tensorflow/core/user_ops$ bazel build --config opt //tensorflow/core/user_ops:my_op.cc
INFO: Found 1 target...
INFO: Elapsed time: 1.493s, Critical Path: 0.01s
(vent)user#server:/dir/tensorflow/tensorflow/core/user_ops$
I thought it was something wrong with my cache so I did a 'bazel clean' and then tried to rebuild the example op zero_out.so, but I got the same problem even though yesterday I was able to successfully run zero_out.so from //bazel-bin/tensorflow/core/user_ops. There's nothing wrong with bazel since I was able to start building tensorflow from source without it quitting on me. My build file in //tensorflow/core/user_ops looks like this:
load("//tensorflow:tensorflow.bzl", "tf_custom_op_library")
tf_custom_op_library(
name = "zero_out.so",
srcs = ["zero_out.cc"],
)
tf_custom_op_library(
name = "my_op.so",
srcs = ["my_op.cc"],
deps = ["#t//:libt"]
)
I've been looking around for a couple hours, but I can't find any help and I don't think I'm looking in the right places. Does this have something to do with the bazel clean deleting some important files? None of my BUILD or WORKSPACE files were changed and nothing on my server has changed.
I'm using Bazel v0.5.1 on Linux with TF v1.2.
Solution to the problem was simply because I had accidentally changed my_op.so to my_op.cc in the build command.

Unable to build the TensorFlow model using bazel build

I have set up the TensorFlow server in a docker machine running on a windows machine by following the instructions from https://tensorflow.github.io/serving/serving_basic. I am successfully able to build and run the mnist_model. However, when I am trying to build the model for the wide_n_deep_tutorial example by running the following command "bazel build //tensorflow_serving/example:wide_n_deep_tutorial.py" the model is not successfully built as there are no files generated in bazel-bin folder.
Since there is no error message displayed while building the model, I am unable to figure out the problem. I would really appreciate if someone can help me debug and solve the problem.
You are just guessing the command line here as there is no target in the BUILD file of tensorflow serving for wide_n_deep_tutorial.py.
You can only build mnist and inception targets as of today.
By adding the target for wide and deep model in the BUILD file solves the problem.
Added the following to the BUILD file:
py_binary(
name = "wide_n_deep_model",
srcs = [
"wide_n_deep_model.py",
],
deps = [
"//tensorflow_serving/apis:predict_proto_py_pb2",
"//tensorflow_serving/apis:prediction_service_proto_py_pb2",
"#org_tensorflow//tensorflow:tensorflow_py",
],
)

Yocto SDK, QtWebEngine: Unknown module(s) in QT: webengine

I'm doing my first steps with Qt and QtWebEngine on an embedded board (i.MX6), using Yocto. Using provided example recipes, like the quicknanobrowser, works nicely on the target. So I can't confirm this answer which claims that WebEngine is not available on embedded platforms.
Now I want to write my own QML application and deploy it on the board. With the recipe meta-toolchain-qt5 I created an SDK and installed it. In QtCreator I set all paths to the SDK installation and tried to build it, but got this error:
Project ERROR: Unknown module(s) in QT: webengine
11:13:13: The process "/opt/poky/1.8/sysroots/x86_64-pokysdk-linux/usr/bin/qt5/qmake" exited with code 3.
It turned out that WebEngine was not included in the SDK. Thanks to this answer, I fixed that by putting the following to my own packagegroup-qt5-toolchain-target.bbappend file:
RDEPENDS_${PN} += " \
qtwebengine \
qtwebengine-qmlplugins \
qtquickcontrols-qmlplugins \
qtwebengine-examples \
"
Then reinstalled the SDK. Now it seems that all WebEngine files are available in the SDK installation (the zsh glob pattern below matches all directories in any subdirectory of /opt/poky/1.8/, which contain "webengine", case-insensitively):
% ls -1 -d (#i)/opt/poky/1.8/**/*webengine*(/)
/opt/poky/1.8/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtWebEngine/
/opt/poky/1.8/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtWebEngine/5.4.3/QtWebEngine/
/opt/poky/1.8/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtWebEngineWidgets/
/opt/poky/1.8/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtWebEngineWidgets/5.4.3/QtWebEngineWidgets/
/opt/poky/1.8/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/lib/qt5/qml/QtWebEngine/
/opt/poky/1.8/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/share/qt5/examples/webengine/
/opt/poky/1.8/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/share/qt5/examples/webenginewidgets/
/opt/poky/1.8/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/share/qt5/translations/qtwebengine_locales/
Still, I get the same Unknown module error. This is independent of QtCreator, and can also be shown by directly calling qmake:
% source /opt/poky/1.8/environment-setup-cortexa9hf-vfp-neon-poky-linux-gnueabi
% /opt/poky/1.8/sysroots/x86_64-pokysdk-linux/usr/bin/qt5/qmake /home/me/test/test.pro -r -spec linux-oe-g++ CONFIG+=debug CONFIG+=declarative_debug CONFIG+=qml_debug
Project ERROR: Unknown module(s) in QT: webengine
The project itself should be fine, because it compiles and runs without problems on the Desktop installation.
Any ideas? Are there maybe still some files missing in the SDK? Where does qmake search for the modules? How can I tell qmake where to find the WebEngine installation?
In /opt/poky/1.8/environment-setup-cortexa9hf-vfp-neon-poky-linux-gnueabi
add sh /opt/poky/1.8/sysroots/x86_64-pokysdk-linux/environment-setup.d/qt5.sh
This will set up the Qt5 environment.