KhronosGroup / KhronosGroup/OpenCL-Guide

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

Open
#33 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
CMake
Stars
711
Forks
70
PR merge metrics
No merged PRs in 30d

Description

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
#include

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 ](https://github.com/microsoft/WSL/issues/6951)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.

Contributor guide

Open the contributing guide

Research direction

No repository file or test is named. Start by reviewing the issue body, the pocl-opencl-icd and clinfo references, and the linked WSL discussion to assess whether the guide should explain Docker OpenCL ICD setup and the host/container distinction; the payload does not define a specific documentation change or completion test.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, docker, ubuntu
Domain
documentation, infrastructure
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.