doe300 / VC4CL

OpenCL implementation running on the VideoCore IV GPU of the Raspberry Pi models
MIT License
728 stars 80 forks source link

clinfo can't find VideoCore on Raspi 3B+, and return `Number of platforms 0` #110

Closed physpeach closed 2 years ago

physpeach commented 2 years ago

I have referenced mainly two links below for installing VC4CL on Raspi 3B+ (debian).

Build seems to be successful, and I can see libVC4CL.so. But clinfo returns Number of platforms 0. Is there anything I am not aware of?

Here's my process for building from plain debian.

$ sudo apt update
$ sudo apt upgrade

$ sudo apt -y install cmake git
$ sudo apt -y install ocl-icd-opencl-dev ocl-icd-dev opencl-headers
$ sudo apt -y install clinfo
$ sudo apt -y install libraspberrypi-dev

$ sudo apt -y install clang clang-format clang-tidy

$ mkdir ~/github/vc4c
$ cd ~/github/vc4c
$ git clone git@github.com/doe300/VC4CLStdLib.git
$ git clone git@github.com/doe300/VC4CL.git
$ git clone git@github.com/doe300/VC4C.git

$ cd VC4CLStdLib
$ mkdir build
$ cd build
$ cmake ..
$ make -j2
$ sudo make install
$ sudo ldconfig

$ cd ../../VC4C
$ mkdir build
$ cd build
$ cmake ..
$ make -j2
$ sudo make install
$ sudo ldconfig

$ cd ../../opencl/VC4CL
$ mkdir build
$ cd build
$ cmake ..
$ make
$ sudo make install
$ sudo ldconfig

$ sudo LD_PRELOAD=src/libVC4CL.so clinfo
Number of platforms        0

This is the first time to submit a issue on Github.

doe300 commented 2 years ago

Can you check following:

  1. Does the file /etc/OpenCL/vendors/VC4CL.icd exist and contain the correct path to the installed VC4CL.so library?
  2. What is the output of e.g. nm -D <path/to/the>/libVC4CL.so | grep 'clCreateKernel'?
physpeach commented 2 years ago
  1. /etc/OpenCL/... does not exist.
  2. below
    $ nm -D /usr/local/lib/libVC4CL.so | grep 'clCreateKernel'
    00151adc T clCreateKernel
    00151fd0 T clCreateKernelsInProgram
    • I found /usr/local/include/vc4cc and /usr/local/include/vc4cl-stdlib

Thank you for fast comment.

physpeach commented 2 years ago

I've rebuilt and installed VC4CL for checking message.

Install the project...
-- Install configuration: "Debug"
-- Installing: /usr/local/lib/libVC4CL.so.0.4.9999
-- Up-to-date: /usr/local/lib/libVC4CL.so.1.2
-- Set runtime path of "/usr/local/lib/libVC4CL.so.0.4.9999" to "/usr/local/lib"
-- Up-to-date: /usr/local/lib/libVC4CL.so
-- Up-to-date: /usr/local/share/vc4cl/VC4CL-targets.cmake
-- Up-to-date: /usr/local/share/vc4cl/VC4CL-targets-debug.cmake
-- Installing: /usr/local/bin/v3d_info
-- Set runtime path of "/usr/local/bin/v3d_info" to "/usr/local/lib"
-- Installing: /usr/local/bin/v3d_profile
-- Set runtime path of "/usr/local/bin/v3d_profile" to "/usr/local/lib"
-- Installing: /usr/local/bin/vc4cl_dump_analyzer
-- Set runtime path of "/usr/local/bin/vc4cl_dump_analyzer" to "/usr/local/lib"
doe300 commented 2 years ago

So it looks like the symbols in the VC4CL library mismatch with what clinfo expects. There are two different ways that should solve this:

  1. Rebuild VC4CL (no need to rebuild VC4C) with the CMake flag -DBUILD_ICD=ON and install it again. Now the /etc/OpenCL/... file should exist and clinfo should be able to find the platform via the ICD loader. (the global way)
  2. Run clinfo with LD_PRELOAD=<path/to/VC4CL/build/src/lib>/OpenCL.so (or alternatively LD_LIBRARY_PATH=<path/to/VC4CL/build/src/lib>). This is a symlink to the libVC4CL.so you tried before, but with the library name that clinfo expects. (the local way)
physpeach commented 2 years ago

The problem has been solved. Many thanks