1

I'm trying to code an opencl C++ application on an old Ubuntu laptop. It has two GPU's which are shown when I run lspci | grep VGA:

00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)
01:00.0 VGA compatible controller: NVIDIA Corporation GK107M [GeForce GT 650M] (rev a1)

Now, I've checked whether each GPU supports OpenCL or not, turns out the NVIDIA one does not support OpenCL but the Intel one does.

When I run clinfo I get:

  Platform Name                                   rusticl
  Platform Vendor                                 Mesa/X.org
  Platform Version                                OpenCL 3.0 
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_byte_addressable_store cl_khr_create_command_queue cl_khr_expect_assume cl_khr_extended_versioning cl_khr_icd cl_khr_il_program cl_khr_spirv_no_integer_wrap_decoration
  Platform Extensions with Version                cl_khr_byte_addressable_store                                    0x400000 (1.0.0)
                                                  cl_khr_create_command_queue                                      0x400000 (1.0.0)
                                                  cl_khr_expect_assume                                             0x400000 (1.0.0)
                                                  cl_khr_extended_versioning                                       0x400000 (1.0.0)
                                                  cl_khr_icd                                                       0x400000 (1.0.0)
                                                  cl_khr_il_program                                                0x400000 (1.0.0)
                                                  cl_khr_spirv_no_integer_wrap_decoration                          0x400000 (1.0.0)
  Platform Numeric Version                        0xc00000 (3.0.0)
  Platform Extensions function suffix             MESA
  Platform Host timer resolution                  1ns

  Platform Name                                   Clover
  Platform Vendor                                 Mesa
  Platform Version                                OpenCL 1.1 Mesa 24.0.9-0ubuntu0.2
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_icd
  Platform Extensions function suffix             MESA

  Platform Name                                   rusticl
Number of devices                                 0

  Platform Name                                   Clover
Number of devices                                 0

NULL platform behavior
  clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...)  rusticl
  clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...)   <error: 0 devices, multiple matching platforms!>
  clCreateContext(NULL, ...) [default]            No devices found in platform
  clCreateContext(NULL, ...) [other]              <error: no devices in non-default plaforms>
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_DEFAULT)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL)  No devices found in platform

ICD loader properties
  ICD loader Name                                 OpenCL ICD Loader
  ICD loader Vendor                               OCL Icd free software
  ICD loader Version                              2.3.2
  ICD loader Profile                              OpenCL 3.0

When I run this C++ code I get the following error:

    err = clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, 1, &device_id, NULL);

    if (err != CL_SUCCESS)
        printf("Error: Failed to create a device group! %d\n", err);

This results in the following output:

2 platform(s) found

Error: Failed to create a device group! -1

Which the error code corresponds to: CL_DEVICE_NOT_FOUND

Why can it not find the device? Is it default opting in for the nvidia gpu and if so how can I swap for the intel one?

4
  • 1
    According to this techpowerup.com/gpu-specs/geforce-gt-650m.c547 your Nvidia GPU does support OpenCL. However, as it is old, up-to-date drivers will no longer support it. I think you can use driver 470 for Kepler generation GPUs like yours. I don't know how to use OpenCL on Intel GPUs. I thought Intel integrated graphics didn't support OpenCL, but I may be wrong. Commented Oct 31, 2024 at 10:39
  • FWIW I have an old build of Ubuntu 20.04 with Nvidia 470 driver so I can still use my old Tesla K20X which is also Kepler generation. That's no guarantee however, it will work for yours also. Commented Oct 31, 2024 at 11:06
  • 1
    @SimonGoater I've installed the correct drivers for 470 kepler drivers and it worked! I wasn't aware of the fact that my drivers don't support it, thanks! Commented Oct 31, 2024 at 11:08
  • @SimonGoater I ran sudo apt install nvidia-driver-470 and installed the drivers from nvidia.com/en-us/drivers/details/196213 I'm not sure which one fixed it but after a reboot it now works. Commented Oct 31, 2024 at 11:09

1 Answer 1

0

Nvidia has the OpenCL runtime included in the drivers, sudo apt install nvidia-driver-470 is indeed the latest supported driver version on the GTX 650M.

Regarding OpenCL on the Intel iGPU: The new Intel GPU OpenCL runtime on Linux only supports 8th Gen or later. For 3rd Gen you need beignet, but that unfortunately has been abandoned and doesn't build anymore with current compilers.

You can install the OpenCL CPU runtime though, see instructions here: https://github.com/ProjectPhysX/OpenCL-Wrapper?tab=readme-ov-file#getting-started

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.