Opened 6 weeks ago

Last modified 6 weeks ago

#74263 assigned defect

pyopencl in python 3.11 crashes at initialization

Reported by: lpagani91 Owned by: petrrr
Priority: Normal Milestone:
Component: ports Version: 2.12.5
Keywords: Cc:
Port: py311-pyopencl

Description

pyopencl only exists for python 3.10 and 3.11. After installing python3.11 and launching ipython-3.11, i get this :

In [1]: import pyopencl

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.4.6 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
AttributeError: _ARRAY_API not found
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
ImportError: numpy.core.multiarray failed to import

The above exception was the direct cause of the following exception:

ImportError                               Traceback (most recent call last)

numpy-3.11 version is

The following ports are currently installed:
  py311-numpy @2.4.6_0+gfortran+openblas (active)

Change History (3)

comment:1 Changed 6 weeks ago by lpagani91

this is somewhat similar to my previous ticket #69350 on the subject.

comment:2 Changed 6 weeks ago by jmroot (Joshua Root)

Owner: set to petrrr
Status: newassigned

comment:3 Changed 6 weeks ago by lpagani91

I am still having the same problem in 2026 as what I mentioned in #69350...

I am now running with Macports 2.12.5 environment, made a fresh reinstall of all my ports. Since pyopencl crashes at start in python3.11 and is not available for python3.14 inside Macports, I collected it using PIP-3.14 :

laurent>sudo -H pip-3.14 install pyopencl
Collecting pyopencl
  Downloading pyopencl-2026.1.2-cp314-cp314-macosx_10_15_x86_64.whl.metadata (4.7 kB)
Requirement already satisfied: numpy in /opt/local/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/site-packages (from pyopencl) (2.5.1)
Requirement already satisfied: platformdirs>=2.2 in /opt/local/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/site-packages (from pyopencl) (4.11.0)
Collecting pytools>=2025.1.6 (from pyopencl)
  Downloading pytools-2026.1.1-py3-none-any.whl.metadata (2.9 kB)
Requirement already satisfied: typing_extensions>=4.6 in /opt/local/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/site-packages (from pyopencl) (4.16.0)
Collecting siphash24>=1.6 (from pytools>=2025.1.6->pyopencl)
  Downloading siphash24-1.8-cp314-cp314-macosx_10_13_x86_64.whl.metadata (3.2 kB)
Downloading pyopencl-2026.1.2-cp314-cp314-macosx_10_15_x86_64.whl (438 kB)
Downloading pytools-2026.1.1-py3-none-any.whl (99 kB)
Downloading siphash24-1.8-cp314-cp314-macosx_10_13_x86_64.whl (77 kB)
Installing collected packages: siphash24, pytools, pyopencl
Successfully installed pyopencl-2026.1.2 pytools-2026.1.1 siphash24-1.8

I tested that i could import pyopencl in python3.14

LOC_OL>python3.14
Python 3.14.6 (main, Jun 10 2026, 15:47:22) [Clang 11.0.3 (clang-1103.0.32.62)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyopencl
>>>

however, trying to run the test.py mentioned in https://trac.macports.org/ticket/69350#comment:1 still crashes :

LOC_OL>python test_pyopencl.py 
TRYING PLATFORM 0
<pyopencl.Platform 'Apple' at 0x7fff0000> [<pyopencl.Device 'Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz' on 'Apple' at 0xffffffff>]
Traceback (most recent call last):
  File "/Users/laurent/Transfert-Radiatif/LOC_OL/test_pyopencl.py", line 38, in <module>
    program =  cl.Program(context, source).build(args)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/site-packages/pyopencl/__init__.py", line 577, in build
    self._prg, was_cached = self._build_and_catch_errors(
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
            lambda: create_built_program_from_source_cached(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                self._context, self._source, options_bytes, devices,
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                cache_dir=cache_dir, include_path=include_path),
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            options_bytes=options_bytes, source=self._source)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/site-packages/pyopencl/__init__.py", line 629, in _build_and_catch_errors
    raise err
pyopencl._cl.RuntimeError: clBuildProgram failed: BUILD_PROGRAM_FAILURE - clBuildProgram failed: BUILD_PROGRAM_FAILURE - clBuildProgram failed: BUILD_PROGRAM_FAILURE

Build on <pyopencl.Device 'Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz' on 'Apple' at 0xffffffff>:


(options: -D Nx=128 -I /opt/local/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/site-packages/pyopencl/cl)
(source saved as /var/folders/r0/j6n9nts53j13kfmd14_mkjwm0000gn/T/tmpm_tl41p0.cl)

However, since this is not directly linked to Macports anymore, you might consider it is none of your business... Fair enough. Simply, I wonder whether a true Macports install of pyopencl in Python 3.14 would help ?

Note: See TracTickets for help on using tickets.