dividiti / ck-caffe

Collective Knowledge workflow for Caffe to automate installation across diverse platforms and to collaboratively evaluate and optimize Caffe-based workloads across diverse hardware, software and data sets (compilers, libraries, tools, models, inputs):
http://cKnowledge.org
BSD 3-Clause "New" or "Revised" License
193 stars 40 forks source link

"ck install package:lib-caffe-bvlc-opencl-clblast-universal-tune " failed #137

Closed dohai90 closed 6 years ago

dohai90 commented 6 years ago

Hello, Recently, I have read " ck-caffe-firefly-rk3399/script/batch_size-libs-models/analysis.20170531.ipynb " and found that caffe with opencl-blast-tune give the highest performance on firefly rk3399 board. So I try to install "lib-caffe-bvlc-opencl-clblast-universal-tune" package. However it's failed as below:

[ 46%] Built target clblast_client_xher
Scanning dependencies of target clblast_sample_sgemm_batched
[ 46%] Building CXX object CMakeFiles/clblast_sample_sgemm_batched.dir/samples/sgemm_batched.cpp.o
/home/firefly/CK/local/env/641db234bf0b237f/src/samples/sgemm_batched.cpp: In function ‘int main()’:
/home/firefly/CK/local/env/641db234bf0b237f/src/samples/sgemm_batched.cpp:67:32: error: ‘cl’ was not declared in this scope
   auto platforms = std::vector<cl::Platform>();
                                ^
/home/firefly/CK/local/env/641db234bf0b237f/src/samples/sgemm_batched.cpp:67:44: error: template argument 1 is invalid
   auto platforms = std::vector<cl::Platform>();
                                            ^
/home/firefly/CK/local/env/641db234bf0b237f/src/samples/sgemm_batched.cpp:67:44: error: template argument 2 is invalid
/home/firefly/CK/local/env/641db234bf0b237f/src/samples/sgemm_batched.cpp:68:3: error: ‘cl’ is not a class, namespace, or enumeration
   cl::Platform::get(&platforms);
   ^
/home/firefly/CK/local/env/641db234bf0b237f/src/samples/sgemm_batched.cpp:73:30: error: the value of ‘cl’ is not usable in a constant expression
   auto devices = std::vector<cl::Device>();
                              ^
/home/firefly/CK/local/env/641db234bf0b237f/src/samples/sgemm_batched.cpp:67:32: note: ‘cl’ was not declared ‘constexpr’
   auto platforms = std::vector<cl::Platform>();
                                ^
/home/firefly/CK/local/env/641db234bf0b237f/src/samples/sgemm_batched.cpp:73:40: error: type/value mismatch at argument 1 in template parameter list for ‘template<class _Tp, class _Alloc> class std::vector’
   auto devices = std::vector<cl::Device>();
                                        ^
/home/firefly/CK/local/env/641db234bf0b237f/src/samples/sgemm_batched.cpp:73:40: note:   expected a type, got ‘cl’
/home/firefly/CK/local/env/641db234bf0b237f/src/samples/sgemm_batched.cpp:73:40: error: template argument 2 is invalid
/home/firefly/CK/local/env/641db234bf0b237f/src/samples/sgemm_batched.cpp:79:39: error: the value of ‘cl’ is not usable in a constant expression
   auto device_as_vector = std::vector<cl::Device>{device};
                                       ^
/home/firefly/CK/local/env/641db234bf0b237f/src/samples/sgemm_batched.cpp:67:32: note: ‘cl’ was not declared ‘constexpr’
   auto platforms = std::vector<cl::Platform>();
                                ^
/home/firefly/CK/local/env/641db234bf0b237f/src/samples/sgemm_batched.cpp:79:49: error: type/value mismatch at argument 1 in template parameter list for ‘template<class _Tp, class _Alloc> class std::vector’
   auto device_as_vector = std::vector<cl::Device>{device};
                                                 ^
/home/firefly/CK/local/env/641db234bf0b237f/src/samples/sgemm_batched.cpp:79:49: note:   expected a type, got ‘cl’
/home/firefly/CK/local/env/641db234bf0b237f/src/samples/sgemm_batched.cpp:79:49: error: template argument 2 is invalid
/home/firefly/CK/local/env/641db234bf0b237f/src/samples/sgemm_batched.cpp:80:18: error: ‘cl’ is not a class, namespace, or enumeration
   auto context = cl::Context(device_as_vector);
                  ^
/home/firefly/CK/local/env/641db234bf0b237f/src/samples/sgemm_batched.cpp:81:16: error: ‘cl’ is not a class, namespace, or enumeration
   auto queue = cl::CommandQueue(context, device);
                ^
/home/firefly/CK/local/env/641db234bf0b237f/src/samples/sgemm_batched.cpp:93:19: error: ‘cl’ is not a class, namespace, or enumeration
   auto device_a = cl::Buffer(context, CL_MEM_READ_WRITE, host_a.size()*sizeof(float));
                   ^
/home/firefly/CK/local/env/641db234bf0b237f/src/samples/sgemm_batched.cpp:94:19: error: ‘cl’ is not a class, namespace, or enumeration
   auto device_b = cl::Buffer(context, CL_MEM_READ_WRITE, host_b.size()*sizeof(float));
                   ^
/home/firefly/CK/local/env/641db234bf0b237f/src/samples/sgemm_batched.cpp:95:19: error: ‘cl’ is not a class, namespace, or enumeration
   auto device_c = cl::Buffer(context, CL_MEM_READ_WRITE, host_c.size()*sizeof(float));
                   ^
CMakeFiles/clblast_sample_sgemm_batched.dir/build.make:62: recipe for target 'CMakeFiles/clblast_sample_sgemm_batched.dir/samples/sgemm_batched.cpp.o' failed
make[2]: *** [CMakeFiles/clblast_sample_sgemm_batched.dir/samples/sgemm_batched.cpp.o] Error 1
CMakeFiles/Makefile2:675: recipe for target 'CMakeFiles/clblast_sample_sgemm_batched.dir/all' failed
make[1]: *** [CMakeFiles/clblast_sample_sgemm_batched.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 47%] Linking CXX executable clblast_client_xsyr
[ 47%] Built target clblast_client_xsyr
[ 47%] Linking CXX executable clblast_client_xtrsv
[ 47%] Built target clblast_client_xtrsv
[ 47%] Linking CXX executable clblast_tuner_xdot
[ 47%] Built target clblast_tuner_xdot
[ 47%] Linking CXX executable clblast_tuner_xgemm
[ 47%] Built target clblast_tuner_xgemm
[ 47%] Linking CXX executable clblast_tuner_xgemm_direct
[ 47%] Built target clblast_tuner_xgemm_direct
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
Error: build failed!
`
I guessed this failure results from CMake can not find clBLAS when installing CLBlast as below:
`Using scripts from /home/firefly/CK/ck-math/package/lib-clblast-master-universal-tune

Cloning package from https://github.com/CNugteren/CLBlast/ ...
Cloning into 'src'...
remote: Counting objects: 13194, done.
remote: Total 13194 (delta 0), reused 0 (delta 0), pack-reused 13194
Receiving objects: 100% (13194/13194), 5.10 MiB | 635.00 KiB/s, done.
Resolving deltas: 100% (9616/9616), done.
Checking connectivity... done.

Checking out branch 1.2.0 ...

Note: checking out '1.2.0'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at 5d5e3f9... Updated to CLBlast version 1.2.0

Cleaning ...

Executing extra script ...

CMake configure flags:

   -DOPENCL_LIBRARIES=/usr/lib/arm-linux-gnueabihf/libOpenCL.so  -DTUNERS=ON  -DCLTUNE_ROOT:PATH=/home/firefly/CK/local/env/3c84e66d69945838/install  -DSAMPLES=ON  -DVERBOSE=OFF  -DCLIENTS=ON

Executing cmake ...
-- Building CLBlast with OpenCL API (default)
-- Could NOT find 'clBLAS.h', install clBLAS or set CLBLAS_ROOT
-- Could NOT find clBLAS library, install it or set CLBLAS_ROOT
-- Could NOT find clBLAS (missing:  CLBLAS_INCLUDE_DIRS CLBLAS_LIBRARIES) 
-- Configuring done
-- Generating done

Is this issue related to this one https://github.com/CNugteren/CLBlast/issues/114 and this one https://github.com/CNugteren/CLBlast/pull/101.

Hope your help @psyhtest and @gfursin Thank you.

gfursin commented 6 years ago

Hi @dohai90. Thanks for reporting this issue. We are now awfully busy finishing ReQuEST tournament for ASPLOS (in a week), but will try to check/solve it shortly after!

fvella commented 6 years ago

Hi @dohai90 I am going to reproduce your error. Could you please print out your ck environment? ck show env

dohai90 commented 6 years ago

Hi @fvella, I attached ck env here. log_env.txt

Thank you.

fvella commented 6 years ago

I unsuccessfully tried to reproduce your issue on Odroid system. The only difference with your ck env is gcc compiler. I am using GNU C compiler 6.3.0. Do you have OpenCL header files installed?

psyhtest commented 6 years ago

Specifically, do you have https://github.com/ARM-software/ComputeLibrary/blob/master/include/CL/cl2.hpp e.g. in /usr/include/CL?

dohai90 commented 6 years ago

Dear all,

I try to install package:lib-caffe-bvlc-opencl-clblast-universal-tune on both firefly and odroid board but all failed with the same reason. I attached here failed log for odroid and its env. Error_log.txt ck show env.txt

However, I can install package:lib-caffe-bvlc-opencl-clblast-universal successful. The different between cmake config that I found that it is -- Found OpenCL: /usr/include
-- Found CLTune: /home/odroid/CK-TOOLS/tool-cltune-master-2.7.0-gcc-5.4.0-linux-32/install/include
-- Found CBLAS: /usr/include
-- Could NOT find 'clBLAS.h', install clBLAS or set CLBLAS_ROOT -- Could NOT find clBLAS library, install it or set CLBLAS_ROOT -- Could NOT find clBLAS (missing: CLBLAS_INCLUDE_DIRS CLBLAS_LIBRARIES) -- Configuring done -- Generating done when I tried to install "tune" version. I also try to find "clBLAS.h" file but there is no file like that. Is that the reason for this error? If that is the reason, how can I install "clBLAS.h"?

@psyhtest I have already included CL folder in /usr/include/CL.

Thank you.

psyhtest commented 6 years ago

@dohai90 CLBlast needs either CBLAS or CLBLAS for validation. As you can see, CBLAS is found, so you can ignore the CLBLAS errors.

psyhtest commented 6 years ago

@dohai90 Please share the contents of your /usr/include/CL/ folder e.g.:

anton@odroid:~$ ls -la /usr/include/CL/   
total 764
drwxr-xr-x  2 root  root   4096 Sep 18  2017 .
drwxr-xr-x 91 root  root  20480 Mar 15 17:29 ..
-rw-r--r--  1 root  root  61787 Aug 19  2016 cl.h
-rw-r--r--  1 root  root 299120 Nov 16  2015 cl.hpp
-rw-r--r--  1 anton dvdt 299999 Sep 18  2017 cl2.hpp
-rw-r--r--  1 root  root   5122 Aug 19  2016 cl_d3d10.h
-rw-r--r--  1 root  root  14238 Aug 19  2016 cl_ext.h
-rw-r--r--  1 root  root   7583 Aug 19  2016 cl_gl.h
-rw-r--r--  1 root  root   2869 Aug 19  2016 cl_gl_ext.h
-rw-r--r--  1 root  root  41566 Aug 19  2016 cl_platform.h
-rw-r--r--  1 root  root   1993 Aug 19  2016 opencl.h
dohai90 commented 6 years ago

This is the content of /usr/include/CL:

firefly@firefly:~$ ls -la /usr/include/CL
total 768
drwxr-xr-x  2 root root   4096 Mar 20 02:16 .
drwxr-xr-x 79 root root  20480 Mar 20 02:16 ..
-rw-r--r--  1 root root 299262 Mar 20 02:16 cl2.hpp
-rw-r--r--  1 root root   4859 Mar 20 02:16 cl_d3d10.h
-rw-r--r--  1 root root   4853 Mar 20 02:16 cl_d3d11.h
-rw-r--r--  1 root root   5157 Mar 20 02:16 cl_dx9_media_sharing.h
-rw-r--r--  1 root root   5036 Mar 20 02:16 cl_egl.h
-rw-r--r--  1 root root  13999 Mar 20 02:16 cl_ext.h
-rw-r--r--  1 root root   2630 Mar 20 02:16 cl_gl_ext.h
-rw-r--r--  1 root root   7343 Mar 20 02:16 cl_gl.h
-rw-r--r--  1 root root  61545 Mar 20 02:16 cl.h
-rw-r--r--  1 root root 281446 Mar 20 02:16 cl.hpp
-rw-r--r--  1 root root  41127 Mar 20 02:16 cl_platform.h
-rw-r--r--  1 root root   1754 Mar 20 02:16 opencl.h
psyhtest commented 6 years ago

Hmm, don't see anything particularly suspicious... We may need help from @cnugteren here.

CNugteren commented 6 years ago

The error seems to occur with one of the samples, so nothing critical there. This particular sample is based on the C++ API of OpenCL, which is "cl.hpp". When running CLBlast's CMake, it will download this file from Khronos through this URL and place it in the samples folder. I see you also have the file already on your system installed, so not sure why it doesn't compile. Perhaps the download failed? Do you have an internet connection on that system? Or perhaps you have an incompatible cl.hpp elsewhere on the system installed.

But in this case I would suggest not to compile the sample, or do you really need it? You can set -DSAMPLES=OFF to CMake.

gfursin commented 6 years ago

Hi all. I just added more parameters to build CLBlast via CK: --env.CK_CLTUNE_TUNERS --env.CK_CLTUNE_CLIENTS --env.CK_CLTUNE_SAMPLES So, it's now possible to turn off samples as suggested by @CNugteren as following:

$ ck pull repo:ck-math
$ ck install package:lib-clblast-master-universal-tune --env.CK_CLTUNE_SAMPLES=OFF

Hope it's of any help ...

CNugteren commented 6 years ago

Thanks @gfursin. A bit wrongly named perhaps (CLTune instead of CLBlast), but it will surely fix the issue :-)

gfursin commented 6 years ago

Hi @CNugteren . I actually fixed env names from CK_CLTUNE to CLBLAST, i.e.

--env.CLBLAST_SAMPLES
--env.CLBLAST_TUNERS
--env.CLBLAST_CLIENTS
--env.CLBLAST_VERBOSE

i.e.

$ ck install package:lib-clblast-master-universal-tune --env.CLBLAST_SAMPLES=OFF
dohai90 commented 6 years ago

@CNugteren, as your comment, the package needs to download other files from this link which is blocked by our university, I think that is the reason for this issue @gfursin, I have tried your solution and it works.

Thank all for your kindly help.

gfursin commented 6 years ago

Sure, @dohai90, you are welcome! And thanks @CNugteren for solution too! By the way, we should move such OpenCL headers to a separate package at some point. We had a ticket about that for a long time but didn't have urgent cases. We will try to check it again: https://github.com/ctuning/ck-env/issues/44