iree-org / iree

A retargetable MLIR-based machine learning compiler and runtime toolkit.
http://iree.dev/
Apache License 2.0
2.83k stars 611 forks source link

Python 3.11 support #11628

Closed oroppas closed 1 year ago

oroppas commented 1 year ago

Request description

IREE's third_party/pybind11 is a bit old (2.9.0.dev1) to support Python 3.11. Python 3.11 support is added in pybind11 v2.10.1.

Bumping up pybind11 version should fix the issue.

What component(s) does this issue relate to?

Python

Additional context

Here's the error message during build:

[2217/4422] Building CXX object runtime/bindings/python/CMakeFiles/iree_runtime_bindings_python_PyExtRt.dir/vm.cc.o
FAILED: runtime/bindings/python/CMakeFiles/iree_runtime_bindings_python_PyExtRt.dir/vm.cc.o 
/usr/bin/clang++ -DCPUINFO_SUPPORTED_PLATFORM=1 -DIREE_HAVE_HAL_EXECUTABLE_LOADER_EMBEDDED_ELF=1 -DIREE_HAVE_HAL_EXECUTABLE_LOADER_SYSTEM_LIBRARY=1 -DIREE_HAVE_HAL_EXECUTABLE_LOADER_VMVX_MODULE=1 -DIREE_HAVE_HAL_LOCAL_SYNC_DRIVER_MODULE=1 -DIREE_HAVE_HAL_LOCAL_TASK_DRIVER_MODULE=1 -DIREE_HAVE_HAL_VULKAN_DRIVER_MODULE=1 -DIREE_HAVE_VMVX_MODULE -DIREE_TRACING_HOOK_CPP_NEW_DELETE=0 -Diree_runtime_bindings_python_PyExtRt_EXPORTS -I/home/ryuta/packages/iree/iree/third_party/cpuinfo/include -I/home/ryuta/packages/iree/iree/third_party/vulkan_headers/include -isystem /usr/include/python3.11 -isystem /home/ryuta/packages/iree/iree/third_party/pybind11/include -isystem /home/ryuta/packages/iree/iree -isystem /home/ryuta/packages/iree/build -isystem /home/ryuta/packages/iree/iree/runtime/src -isystem /home/ryuta/packages/iree/build/runtime/src -isystem /home/ryuta/packages/iree/build/runtime/src/iree/base/internal/flatcc -isystem /home/ryuta/packages/iree/iree/third_party/flatcc/include -isystem /home/ryuta/packages/iree/build/runtime/src/iree/schemas -isystem /home/ryuta/packages/iree/iree/third_party/vulkan_memory_allocator/include -stdlib=libc++ -O2 -g -DNDEBUG -fPIC -fvisibility=hidden -fvisibility=hidden -fno-rtti -fno-exceptions -Werror -Wall -Wno-ambiguous-member-template -Wno-char-subscripts -Wno-extern-c-compat -Wno-gnu-alignof-expression -Wno-gnu-variable-sized-type-not-at-end -Wno-ignored-optimization-argument -Wno-invalid-offsetof -Wno-invalid-source-encoding -Wno-mismatched-tags -Wno-pointer-sign -Wno-reserved-user-defined-literal -Wno-return-type-c-linkage -Wno-self-assign-overloaded -Wno-sign-compare -Wno-signed-unsigned-wchar -Wno-strict-overflow -Wno-trigraphs -Wno-unknown-pragmas -Wno-unknown-warning-option -Wno-unused-command-line-argument -Wno-unused-const-variable -Wno-unused-function -Wno-unused-local-typedef -Wno-unused-private-field -Wno-user-defined-warnings -Wctad-maybe-unsupported -Wfloat-overflow-conversion -Wfloat-zero-conversion -Wfor-loop-analysis -Wformat-security -Wgnu-redeclared-enum -Wimplicit-fallthrough -Winfinite-recursion -Wliteral-conversion -Wnon-virtual-dtor -Woverloaded-virtual -Wpointer-arith -Wself-assign -Wstring-conversion -Wtautological-overlap-compare -Wthread-safety -Wthread-safety-beta -Wunused-comparison -Wvla -fno-lax-vector-conversions -fmacro-prefix-map=/home/ryuta/packages/iree/iree=iree -frtti -fexceptions -I/home/ryuta/packages/iree/iree/third_party/flatcc/include/ -I/home/ryuta/packages/iree/iree/third_party/flatcc/include/flatcc/reflection/ -std=gnu++17 -MD -MT runtime/bindings/python/CMakeFiles/iree_runtime_bindings_python_PyExtRt.dir/vm.cc.o -MF runtime/bindings/python/CMakeFiles/iree_runtime_bindings_python_PyExtRt.dir/vm.cc.o.d -o runtime/bindings/python/CMakeFiles/iree_runtime_bindings_python_PyExtRt.dir/vm.cc.o -c /home/ryuta/packages/iree/iree/runtime/bindings/python/vm.cc
In file included from /home/ryuta/packages/iree/iree/runtime/bindings/python/vm.cc:7:
In file included from /home/ryuta/packages/iree/iree/runtime/bindings/python/./vm.h:12:
In file included from /home/ryuta/packages/iree/iree/runtime/bindings/python/./binding.h:14:
In file included from /home/ryuta/packages/iree/iree/third_party/pybind11/include/pybind11/pybind11.h:13:
In file included from /home/ryuta/packages/iree/iree/third_party/pybind11/include/pybind11/attr.h:13:
In file included from /home/ryuta/packages/iree/iree/third_party/pybind11/include/pybind11/cast.h:16:
/home/ryuta/packages/iree/iree/third_party/pybind11/include/pybind11/detail/type_caster_base.h:482:26: error: member access into incomplete type 'PyFrameObject' (aka '_frame')
            frame = frame->f_back;
                         ^
/usr/include/python3.11/pytypedefs.h:22:16: note: forward declaration of '_frame'
typedef struct _frame PyFrameObject;
               ^
1 error generated.
stellaraccident commented 1 year ago

It usually isn't very disruptive to bump the pybind module. Shouldn't be a problem...

GMNGeoffrey commented 1 year ago

https://github.com/iree-org/iree/commit/beaa511a5807a4aee749c2acd381d791e577990a bumped the pybind submodule to https://github.com/pybind/pybind11/commit/59aa99860c60bd171b9565e9920f125fdb749267. I'm not sure why we stopped at 2.9. @ScottTodd ?

GMNGeoffrey commented 1 year ago

(Progress here is likely to be a bit slow over the holiday though)

ScottTodd commented 1 year ago

I tried to update pybind for this in https://github.com/iree-org/iree/pull/11564, but many things broke... The errors seemed unrelated to Python, so I suspected that something else in our Docker images was unstable.

ScottTodd commented 1 year ago

beaa511 bumped the pybind submodule to pybind/pybind11@59aa998. I'm not sure why we stopped at 2.9. @ScottTodd ?

That was the latest at the time (December 2021, last year)

GMNGeoffrey commented 1 year ago

Ah, I mixed that up with another recent third_party bump you did: https://github.com/iree-org/iree/commit/4293848f0e6d2ed49cdedee458acbdfc14aa5896

ScottTodd commented 1 year ago

Okay, I updated our version of pybind and was able to build the Python bindings on my Windows machine using Python 3.11. I think that fixes this issue as reported, but we should also start building and distributing Python 3.11 wheels for installation through pip.

oroppas commented 1 year ago

I confirmed the update. IREE can be built on my Linux (Fedora 37). Thank you!