{"id":9832,"library":"intel-opencl-rt","title":"Intel oneAPI OpenCL Runtime","description":"The `intel-opencl-rt` PyPI package provides the Intel® oneAPI OpenCL* Runtime library. This is not a Python library with direct importable modules but rather a runtime provider, installing shared libraries (.so, .dll) that other Python OpenCL binding libraries (e.g., `pyopencl`) can then utilize to access Intel GPUs or CPUs with integrated graphics for general-purpose computing. It is part of the broader Intel oneAPI ecosystem and is updated periodically, often in sync with major oneAPI releases.","status":"active","version":"2025.3.3","language":"en","source_language":"en","source_url":"https://www.intel.com/content/www/us/en/developer/tools/oneapi/opencl-runtime.html","tags":["OpenCL","Intel","GPU","CPU","compute","oneAPI","runtime"],"install":[{"cmd":"pip install intel-opencl-rt","lang":"bash","label":"Install the runtime"}],"dependencies":[],"imports":[{"note":"The `intel-opencl-rt` package provides shared libraries (.so/.dll) that are discovered by other OpenCL binding libraries (like `pyopencl`) at runtime. It does not expose Python symbols for direct import.","wrong":"from intel_opencl_rt import OpenCLDevice","symbol":"Intel OpenCL Runtime","correct":"This package is a runtime, not a Python module to be imported directly."}],"quickstart":{"code":"import pyopencl as cl\nimport numpy\n\n# This code assumes intel-opencl-rt has installed the necessary drivers/runtime.\n# pyopencl will automatically find and use the available OpenCL platform.\n\ntry:\n    platform = cl.get_platforms()[0] # Get the first OpenCL platform\n    devices = platform.get_devices() # Get devices for the platform\n    \n    # Filter for Intel devices if desired, or use the first available.\n    intel_devices = [d for d in devices if 'Intel' in d.vendor]\n    device_to_use = intel_devices[0] if intel_devices else devices[0]\n\n    ctx = cl.Context([device_to_use])\n    queue = cl.CommandQueue(ctx)\n\n    a = numpy.random.rand(50000).astype(numpy.float32)\n    b = numpy.random.rand(50000).astype(numpy.float32)\n\n    mf = cl.mem_flags\n    a_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=a)\n    b_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=b)\n    dest_buf = cl.Buffer(ctx, mf.WRITE_ONLY, a.nbytes)\n\n    prg = cl.Program(ctx, \"__kernel void sum(__global const float *a, __global const float *b, __global float *c) { int gid = get_global_id(0); c[gid] = a[gid] + b[gid]; }\").build()\n\n    prg.sum(queue, a.shape, None, a_buf, b_buf, dest_buf)\n    c = numpy.empty_like(a)\n    cl.enqueue_copy(queue, c, dest_buf).wait()\n\n    print(f\"OpenCL platform: {platform.name}\")\n    print(f\"OpenCL device: {device_to_use.name}\")\n    print(f\"Result calculated via OpenCL: {c[:5]}...\")\n    print(f\"Expected result: {(a+b)[:5]}...\")\n    assert numpy.allclose(c, a + b)\n    print(\"OpenCL computation successful!\")\n\nexcept cl.LogicError as e:\n    print(f\"Failed to initialize OpenCL: {e}\")\n    print(\"Please ensure OpenCL drivers are installed and a compatible device is present.\")\nexcept IndexError:\n    print(\"No OpenCL platforms or devices found. Ensure Intel OpenCL runtime is correctly installed and compatible hardware is available.\")\n\n","lang":"python","description":"This quickstart demonstrates how to use `pyopencl` to perform a simple vector addition, leveraging the OpenCL runtime provided by `intel-opencl-rt`. You will first need to install `pyopencl` (e.g., `pip install pyopencl`). The `intel-opencl-rt` package installs the backend necessary for `pyopencl` to find and utilize Intel OpenCL devices."},"warnings":[{"fix":"Instead of trying to import, install the package and then use a Python OpenCL binding library like `pyopencl` or `pylibopencl`. These libraries will automatically detect the installed OpenCL runtime.","message":"This package is not a Python library for direct import. It installs a system runtime (shared libraries) that other OpenCL Python bindings (like `pyopencl`) discover and use. You will not `import intel_opencl_rt` in your Python code.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your system has a supported Intel CPU with integrated graphics or an Intel discrete GPU. Verify that necessary system-level drivers are installed and up-to-date, typically via Intel's driver support assistant or by installing the full oneAPI Base Toolkit.","message":"The `intel-opencl-rt` package provides the *runtime*, but requires compatible Intel hardware (e.g., an Intel integrated GPU or discrete GPU) and potentially system-level drivers to function correctly and provide hardware acceleration.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Prefer installing the oneAPI Base Toolkit for a comprehensive and managed installation. Only use `pip install intel-opencl-rt` if you specifically need just the OpenCL runtime in a Python environment and do not have a full oneAPI installation, or if you encounter issues with system-wide installations.","message":"If you have already installed the Intel oneAPI Base Toolkit, installing `intel-opencl-rt` via pip might be redundant or could potentially lead to version conflicts if the pip package's runtime files conflict with the system-wide oneAPI installation.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Remove the `import intel_opencl_rt` statement. Instead, use a Python OpenCL binding library (e.g., `pyopencl`) which will dynamically link to the runtime provided by this package.","cause":"The `intel-opencl-rt` package is a runtime provider, not a Python module designed for direct import. You should not attempt to `import intel_opencl_rt`.","error":"ModuleNotFoundError: No module named 'intel_opencl_rt'"},{"fix":"Verify that `intel-opencl-rt` is installed (`pip show intel-opencl-rt`). Ensure your system has an Intel CPU with integrated graphics or an Intel GPU. Install or update necessary system-level drivers from Intel. You may also check the output of `clinfo` (if available on your system) to see detected OpenCL platforms.","cause":"This error typically indicates that no OpenCL platforms or devices could be found by `pyopencl`. This can happen if the `intel-opencl-rt` runtime is not correctly installed, drivers are missing, or no compatible Intel hardware is present.","error":"pyopencl.LogicError: clGetPlatformIDs failed (errcode=-1)"}]}