gpuR icon indicating copy to clipboard operation
gpuR copied to clipboard

Intel OpenCL not recognized

Open rstub opened this issue 7 years ago • 8 comments

I have a (Debian stable) system with three OpenCL platforms installed:

$ clinfo | head -21
Number of platforms                               3
  Platform Name                                   Intel Gen OCL Driver
  Platform Vendor                                 Intel
  Platform Version                                OpenCL 2.0 beignet 1.3
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_3d_image_writes cl_khr_image2d_from_buffer cl_khr_depth_images cl_khr_spir cl_khr_icd cl_intel_accelerator cl_intel_subgroups cl_intel_subgroups_short
  Platform Extensions function suffix             Intel

  Platform Name                                   Intel(R) OpenCL
  Platform Vendor                                 Intel(R) Corporation
  Platform Version                                OpenCL 2.0 
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_3d_image_writes cl_khr_byte_addressable_store cl_khr_depth_images cl_khr_fp64 cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_icd cl_khr_image2d_from_buffer cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_spir
  Platform Extensions function suffix             INTEL

  Platform Name                                   Portable Computing Language
  Platform Vendor                                 The pocl project
  Platform Version                                OpenCL 2.0 pocl 0.13, LLVM 3.8.1
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_icd
  Platform Extensions function suffix             POCL

Beignet and POCL have been installed from the Debian repositories. For Intel OpenCL I used the binary installer from Intel. A simple sample program finds all three platforms:

#include <stdio.h>
#include <CL/cl.h>

int main(void)
{
    cl_int err;
    cl_uint numPlatforms = 0;

    err = clGetPlatformIDs(0, NULL, &numPlatforms);
    if (CL_SUCCESS == err)
        printf("Detected OpenCL platforms: %d\n", numPlatforms);
    else
        printf("Error calling clGetPlatformIDs. Error code: %d\n", err);
    return 0;
}

Output:

$ ./platforms 
Detected OpenCL platforms: 3

However, gpuR::detectPlatforms() finds only two of them:

gpuR::detectPlatforms()
#> [1] 2
packageVersion("gpuR")
#> [1] '2.0.0'

I am pretty sure that it is Intel OpenCL that is missing since something similar happens in the OpenCL package: https://github.com/s-u/OpenCL/issues/4

rstub avatar Jan 12 '18 11:01 rstub

You have one GPU (beignet - Intel graphics) and the other two are CPU. You don't need both CPU versions. Since you have beignet I'm guessing your CPU is an Intel one. I suspect the Intel OpenCL is better tuned than Pocl.

znmeb avatar Jan 12 '18 11:01 znmeb

The "Intel(R) OpenCL" platform lists two devices in clinfo, one of them the GPU:

  Platform Name                                   Intel(R) OpenCL
Number of devices                                 2
  Device Name                                     Intel(R) HD Graphics
  Device Vendor                                   Intel(R) Corporation
  Device Vendor ID                                0x8086
  Device Version                                  OpenCL 2.0 
  Driver Version                                  r5.0.63503
  Device OpenCL C Version                         OpenCL C 2.0 
  Device Type                                     GPU
  Device Profile                                  FULL_PROFILE
...
  Device Name                                     Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz
  Device Vendor                                   Intel(R) Corporation
  Device Vendor ID                                0x8086
  Device Version                                  OpenCL 2.0 (Build 475)
  Driver Version                                  1.2.0.475
  Device OpenCL C Version                         OpenCL C 2.0 
  Device Type                                     CPU
  Device Profile                                  FULL_PROFILE

I also suspect that the Intel OpenCL is better tuned. But at the moment I cannot use it with gpuR since it is not recognized.

rstub avatar Jan 12 '18 12:01 rstub

@karlrupp, any thoughts regarding this? detectPlatforms() uses viennacl::ocL::get_platforms() to find available OpenCL platforms. Perhaps an ICD related issue?

@rstub what is your OS (you just say 'Debian' style). I can try to spin up a container in docker and try to replicate the problem.

cdeterman avatar Jan 12 '18 15:01 cdeterman

I am using Debian 9.3:

$ cat /etc/debian_version 
9.3

Concerning base ViennaCL, I have tested this sample program:

#include <iostream>
#define VIENNACL_WITH_OPENCL 1
#include "viennacl/ocl/platform.hpp"

int main(void) {
  std::cout << viennacl::ocl::get_platforms().size() << std::endl;
  return 0;
}

ViennaCL sees all three platforms:

$ ./platforms_vcl 
3

rstub avatar Jan 12 '18 15:01 rstub

Interesting, let me see what I can spin up. That is encouraging that ViennaCL is finding the platforms. It would also help if you could provide the commands you used to install pocl, beignet, and also where you got the Intel OpenCL installer.

cdeterman avatar Jan 12 '18 16:01 cdeterman

@rstub I believe I have a Docker image with pocl and beignet install with apt-get install libpocl1 ocl-icd-opencl-dev beignet. But I want to make sure I install the same binary from Intel you used. Can you provide a link?

cdeterman avatar Jan 12 '18 18:01 cdeterman

I used the drivers from https://software.intel.com/en-us/articles/opencl-drivers#latest_linux_driver, i.e. http://registrationcenter-download.intel.com/akdlm/irc_nas/11396/SRB5.0_linux64.zip.

rstub avatar Jan 12 '18 20:01 rstub

BTW, I have tried to setup a Docker image with only the Intel OpenCL driver. Here the Dockerfile:

FROM rocker/r-ver:3.4.3

ENV OPENCL_INC=/opt/intel/opencl/include \
    OPENCL_LIB=/opt/intel/opencl

RUN apt-get update \
 && apt-get install --yes --no-install-recommends \
            unzip xz-utils wget clinfo \
 && cd /tmp \
 && wget http://registrationcenter-download.intel.com/akdlm/irc_nas/11396/SRB5.0_linux64.zip \
 && unzip SRB5.0_linux64.zip \
 && cd / \
 && tar xJf /tmp/intel-opencl-r5.0-63503.x86_64.tar.xz \
 && tar xJf /tmp/intel-opencl-devel-r5.0-63503.x86_64.tar.xz \
 && tar xJf /tmp/intel-opencl-cpu-r5.0-63503.x86_64.tar.xz \
 && ldconfig \
 && apt-get clean \
 && rm -rf /var/lib/apt/lists/* /tmp/*

COPY platforms.c platforms_vcl.cpp /app/
RUN cd /app \
 && wget http://sourceforge.net/projects/viennacl/files/1.7.x/ViennaCL-1.7.1.tar.gz/download \
 && tar xzvf download \
 && rm download \
 && gcc -I$OPENCL_INC -L$OPENCL_LIB -lOpenCL -o platforms platforms.c \
 && g++ -IViennaCL-1.7.1 -I$OPENCL_INC -L$OPENCL_LIB -lOpenCL -o platforms_vcl platforms_vcl.cpp

WORKDIR /app

I run this with docker run --rm -ti --device /dev/dri:/dev/dri intel-opencl bash. All tests for the OpenCL platform (clinfo, platform and platform_vcl) succeed. But When I install gpuR it ends with this error:

...
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error: package or namespace load failed for ‘gpuR’:
 .onAttach failed in attachNamespace() for 'gpuR', details:
  call: initContexts()
  error: ViennaCL: FATAL ERROR: ViennaCL encountered an unknown OpenCL error. Most likely your OpenCL SDK or driver is not installed properly. In some cases, this error is due to an invalid global work size or several kernel compilation errors.
If you think that this is a bug in ViennaCL, please report it at [email protected] and supply at least the following information:
 * Operating System
 * Which OpenCL implementation (AMD, NVIDIA, etc.)
 * ViennaCL version
Many thanks in advance!
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/usr/local/lib/R/site-library/gpuR’

rstub avatar Jan 12 '18 21:01 rstub