Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*
585 Discussions

DPCPP-SYCL cannot find GPU target from Python (Pybind11)

Jonas5
Beginner
474 Views

I have a simple Pybind11-binding:

#include <CL/sycl.hpp>
#include <pybind11/pybind11.h>

int foo(int a)
{
sycl::queue q(sycl::gpu_selector_v);
sycl::buffer<int, 1> b(&a, sycl::range<1>(1));
q.submit([&](sycl::handler& cgh){
auto acc = b.get_access<sycl::access::mode::read_write>(cgh);
cgh.single_task<class foo>([=](){
acc[0] +=1;
});
});
//accessor
auto acc = b.get_access<sycl::access::mode::read>();
return acc[0];
}

PYBIND11_MODULE(test_binder, m) {
m.def("foo", &foo);
}

 

And a simple script to invoke:

import sys

binder_path = "..."
sys.path.append(binder_path)

from test_binder import *

print(foo(1))


The binder is built in a oneapi-sourced environment, and linked with:

-fsycl -sycl-std=2020 -std=c++20 -fsycl-unnamed-lambda -fPIC


(Cpp-executables built with the same flags are able to execute fine on the GPU.)

 

When running the `.py` script in the sourced environment, it works fine on the CPU. However, when openCL-devices are forced:

export ONEAPI_DEVICE_SELECTOR=opencl:*

I get the following error:

Traceback (most recent call last):
File "...py", line 8, in <module>
print(foo(1))
RuntimeError: No device of requested type available. Please check https://software.intel.com/content/www/us/en/develop/articles/intel-oneapi-dpcpp-system-requirements.html -1 (PI_ERROR_DEVICE_NOT_FOUND)

 

Is it possible to keep the OpenCL-device exposed through the compiled Python-binder?

(AOT-compiling with -fsycl-targets did not resolve the issue)

 

 

0 Kudos
2 Replies
NoorjahanSk_Intel
Moderator
443 Views

Hi,

 

Thanks for posting in Intel Communities.

 

Could you please provide the detailed steps you have followed to build your code?

 

Also please provide the below details:

OS & Hardware details

The compiler version being used

 

Could you please let us know why you are using OpenCL devices?

Also please try with a level_zero device and let us know if you observe the same issue.

ONEAPI_DEVICE_SELECTOR=level_zero:gpu

 

Thanks & Regards,

Noorjahan.


0 Kudos
NoorjahanSk_Intel
Moderator
361 Views

Hi,


As you want to close this thread as mentioned in internal notes, we are going ahead and closing this issue.

If you need any additional information, please submit a new question as this thread will no longer be monitored.


Thanks & Regards,

Noorjahan.


0 Kudos
Reply