Skip to content

CL_PLATFORM_NOT_FOUND_KHR (-1001) while using docker ubuntu22.04 image with GPU enabled. #33

@hungpham3112

Description

@hungpham3112

Hi, I'm new to heterogeneous programming with OpenCL. Today, I'm trying to create workspace using docker image ubuntu22.04 for OpenCL development.

Firstly, I run docker image with GPU enable via --gpus all flag:
docker run --gpus all -it my_container ubuntu:22.04

then I downloaded all the header file (/usr/include/CL/) and ICD (Installable Client Driver) which located in /usr/lib/x86_64-linux-gnu/libOpenCL.so

my toy program main.c in OpenCL:

#define CL_TARGET_OPENCL_VERSION 300

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

int main() {
	cl_device_id my_device_id;
	int result;
	clGetDeviceIDs(
		NULL,
		CL_DEVICE_TYPE_GPU,
		1,
		&my_device_id,
		NULL
	);
	if (result != CL_SUCCESS) {
		printf("Something went wrong\n");
		return 1;
	} else {
		printf("Good");
	}

}

I compiled with gcc main.c -o ./main -lOpenCL, output: clGetPlatformIDs(-1001)

What am I missing in here? How can I develop workflow for OpenCL in docker, I see cuda/opencl image but it seems not maintain anymore.

Edit: After an hour of searching I found that I missed the package called pocl-opencl-icd. Just simply sudo apt install pocl-opencl-icd, now clinfo show it found 1 platform but not CUDA platform in docker env.

Question: What is the relationship between Pocl and OpenCL. Why include pocl in docker container make clinfo can detect platform but in the "normal" environment, I mean the host OS not docker container, I don't need to download pocl-opencl-icd so clinfo still be able to detect platform? What is the different in here? Please enlighten me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions