Troubleshoot DPC++ targeting GPU with and without CUDA - nvidia

I followed the instructions at the below website to test DPC++ on my computer.
https://github.com/intel/llvm/blob/sycl/sycl/doc/GetStartedGuide.md#build-dpc-toolchain
$ ./simple-sycle-app.exe
The results are correct!
I then modified line 23 to target my gpu
// Creating SYCL queue
sycl::queue Queue( sycl::gpu_selector{} );
[18:49]ec2-user$ ./simple-sycl-app-gpu.exe
terminate called after throwing an instance of 'cl::sycl::runtime_error' what(): No device of requested type available. -1 (PI_ERROR_DEVICE_NOT_FOUND) Aborted (core dumped)
did i need to build my dpc environment with CUDA enabled to access my K80 Nvidia GPU? I didn't enable it because CUDA support is apparently still experimental. I thought the whole point of using DPC++ was for me not to need to use CUDA. Should i be able to use my Nvidia gpu with just an nvidia driver and not CUDA?

You need to build llvm compiler with CUDA support. Brief instruction is to
install CUDA development kit, e.g. from here
Build and install Intel's llvm compiler from sources: https://github.com/intel/llvm passing --cuda param to configure command (see instructions on project's README)
use compiler according to this instruction, e.g. like this:
export DPCPP_HOME=~/sycl_workspace
export PATH=$DPCPP_HOME/llvm/build/bin:$PATH
export LD_LIBRARY_PATH=$DPCPP_HOME/llvm/build/lib:$LD_LIBRARY_PATH
clang++ -fsycl -fsycl-targets=nvptx64-nvidia-cuda \
simple-sycl-app.cpp -o simple-sycl-app-cuda.exe

Related

What does the “BUILD_CUDA_STUBS” option do when building OpenCV?

In open CV CMakeLists.txt, there is a flag called "BUILD_CUDA_STUBS":
OCV_OPTION(BUILD_CUDA_STUBS "Build CUDA modules stubs when no CUDA SDK" OFF IF (NOT APPLE_FRAMEWORK) )
What does this means? It sounds like, open cv's doc is a bit limited on the build flag.
It’s poorly, or un-, documented.
If BUILD_CUDA_STUBS is enabled, when building, it (supposedly) adds some code (“CUDA stubs”) to replace the CUDA toolkit(’s drivers? IDK), to enable building CUDA-powered code on a machine that does not have the CUDA toolkit installed.
I recommend you just leave it OFF, which is the default, and install the genuine CUDA toolkit on your machine.

OpenCV Crosscompile for ARM: highgui error (GTK2+)

I'm have build the OpenCV library from source for Zynq (ARM). But, OpenCV was build on the same PC for x86 (PC) also. Firstly, I can execute every example on my PC without any issues. Secondly, I am able to crosscompile and execute every program on the arm target, except the ones including highgui libraries, where I receive the following error:
OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvShowImage, file /home/hristov/workspace/opencv/modules/highgui/src/window.cpp, line 534
terminate called after throwing an instance of 'cv::Exception'
what(): /home/user/workspace/opencv/modules/highgui/src/window.cpp:534: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvShowImage
Yes, I have gone through the forum for solutions for this issue but some answers were unclear and I would like some more detail into this. I have created the OpenCV build for ARM build WITH_GTK and GTK2. Also installed libgtk2.0-dev, pkg-config
However, From another topic on this forum, I learned that the problem lies in setting up the pkg-config: http://answers.opencv.org/question/57945/opencv-gui-with-gtk-2-solved/
Q) Based on the above solution, Do you set the path for PKG_CONFIG_PATH on your ARM platform (Zynq) or on the PC platform (Ubuntu PC)? Because, it is already set to the described path on the ARM platform whereas it is different on the PC Linux platform. More details of the current path is shown below:
PKG_CONFIG_PATH in PC(Ubuntu):
/usr/local/lib/x86_64-linux-gnu/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig
PKG_CONFIG_PATH in ARM (Embedded platform):
/usr/local/lib/arm-linux-gnueabihf/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/arm-linux-gnueabihf/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig
If the pkg-config must be changed on my PC, to the /usr/lib/arm-linux-gnueabihf/pkgconfig/ location, I cannot find any pkg-config in that location. Should I create a new one, by copying the folder from my target?
Q) Also, Should the GTK libraries also be installed in the Target Embedded system (ARM)?
Hope someone can help me with this solution as I have rebuild the libraries umpteen times with many different solutions, but to no avail. Thanks!

Cross compile OpenCV with CUDA on x86-64 host for nvidia tk1 (arm) target using Yocto Project?

I want to build a custom Linux using the Yocto Project for a system using the nvidia tegra k1 processor, which has an arm cortex A 15 (32bit) and a GPU. Furthermore, OpenCV (version >= 3.0) with CUDA support needs to be installed.
Now when Bitbake tries to compile OpenCV with CUDA it crashes because nvcc throws an error Syntax error: word unexpected (expecting ")") which I learned is usually the case if you try to run an nvcc binary that is for the wrong system (e.g. 32bit-nvcc on 64bit-system). So I guess it just runs the nvcc that is suppost for the target system and therefore crashes.
I don't know whether I need to compile using the usual x86-64bit-nvcc of the host system or (if this exists) some cross-compilation-nvcc.
I need to know how I can involve said compiler into bitbake's process that builds OpenCV.
I figured it out:
One needs to use an nvcc binary that supports the host architecture. To specify the target architecture on can pass it cross compilation flags (see http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/#cross-compilation). These are passed via the the cmake flag -DCUDA_NVCC_FLAGS
EXTRA_OECMAKE_append = "-DCUDA_NVCC_EXECUTABLE=${PATH_TO_THE_NVCC_BINARY}"
The whole statement in the bbappend file could look like this
EXTRA_OECMAKE_append = " \
-DCUDA_NVCC_EXECUTABLE=${NVCC_BINARY} \
-DCUDA_NVCC_FLAGS="--compiler-bindir ${GCC_BINARY}" \
"

How to install openCV 3.1 with full cuda toolkit support?

I am installing openCV 3.1 following this guide. However after running CMake I see the following output
NVIDIA CUDA
Use CUFFT: YES
Use CUBLAS: NO
USE NVCUVID: NO
NVIDIA GPU arch: 20 21 30 35
NVIDIA PTX archs: 30
Use fast math: NO
I see that CUBLAS, NVCUVID and fastmath is set to NO. But I have installed cuda toolkit 7.5, so I don't understand why is it still NO, and how can I make so to install with full gpu support?
I am using Ubuntu 16.04, OpenCV 3.1
The guide that you mentioned using does not appear to have a flag related to or set to turn on the fast math feature. As far as I am aware you need to specify this during the cuda toolkit build or it will not be included in the build.
For example if you are using NVCC you must use the --use_fast_math flag; as is indicated here. So it is likely that the CMAKE scripting doesn't have that flag set anywhere either.

opencv error: no GPU support

I have install Cuda 6.5 and opencv 2.4.9 with visual studio 2010, when I run gpu, I get error
Opencv Error: No GPU support(the library is compiled without PGU support) in the row_nogpu, file C:/builds/2_4_Packslave-win32-vc10-shared/opencv/modules/gpu/src/precomp.hpp line 135
I get this error, is any one can help what do I have to do?
Thanks
I believe, you have to actually build the libraries with CUDA support. I Imagine This Guide will be useful.
This can be caused because of following.
Use the flag WITH_CUDA=ON during cmake
You are trying to load the libraries which are compiled without GPU support, after you install opencv make sure you change the libraries path to that of GPU supported once.

Resources