Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
hungpham3112 opened this issue Dec 5, 2023 · 0 comments

Comments

@hungpham3112
Copy link

hungpham3112 commented Dec 5, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant