google-coral / pycoral

Python API for ML inferencing and transfer-learning on Coral devices
https://coral.ai
Apache License 2.0
351 stars 145 forks source link

Python 3.12 support #149

Open virnik0 opened 1 month ago

virnik0 commented 1 month ago

Description

I am trying to build pycoral for use on Ubuntu 24.04 with Python3.12, x86_64 arch.

I have tried few diferent forks, but the latest one and most promissing was faranick's.

Downgrading Python to version 3.11 is not an option given how hardwired 3.12 in the system is. I tried - and only result was corrupted python install and messed-up dependencies (easy to solve with zfs snapshot revert).

I do have tflite_runtime-2.17.0-cp312-cp312-linux_x86_64.whl wheel build from faranick, and libedgetpu1-max_16.0tf2.17.0-1.ubuntu22.04_amd64.deb (which seems to be working fine on Ubuntu 24.04) from the same author. But I am missing pycoral. While I was able to rebuild libcoral and verify that my coraltpu works, I am unable to use python bindings in anything relevant to it due to absence of pycoral.

I have dowgraded bazel to version 5.4.1, otherwise the build would fail much sooner.

Click to expand! ### Issue Type Build/Install ### Operating System Ubuntu ### Coral Device USB Accelerator ### Other Devices _No response_ ### Programming Language _No response_ ### Relevant Log Output ```shell ~/repositories/coral/pycoral# bazel clean --expunge && TF_PYTHON_VERSION=3.12 CFLAGS='-stdlib=libc++ -std=c++17' make INFO: Starting clean (this may take a while). Consider using --async if the clean takes more than several minutes. Starting local Bazel server and connecting to it... Loading: 0 packages loaded Loading: 0 packages loaded Loading: 0 packages loaded Loading: 0 packages loaded Loading: 0 packages loaded Loading: 0 packages loaded Loading: 0 packages loaded Loading: 0 packages loaded Loading: 1 packages loaded Loading: 1 packages loaded PYTHON_BIN_PATH=/usr/bin/python3 bazel build --compilation_mode=opt --copt=-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION --cpu=k8 --linkopt=-L/root/repositories/coral/pycoral/libedgetpu_bin/direct/k8 --linkopt=-l:libedgetpu.so.1 --linkopt=-Wl,--strip-all \ --embed_label='TENSORFLOW_COMMIT=ad6d8cc177d0c868982e39e0823d0efbfb95f04c' \ --stamp \ //src:_pywrap_coral ERROR: Traceback (most recent call last): File ".cache/bazel/_bazel_root/be2d1fe448dd770f03a597a2a9fa3688/external/org_tensorflow/tensorflow/python/tools/api/generator2/generate_api.bzl", line 18, column 34, in ApiInfo, _new_api_info = provider( Error in provider: provider() got unexpected keyword argument 'init' INFO: Repository rules_proto instantiated at: repositories/coral/pycoral/WORKSPACE:129:14: in .cache/bazel/_bazel_root/be2d1fe448dd770f03a597a2a9fa3688/external/org_tensorflow/tensorflow/workspace0.bzl:114:17: in workspace Repository rule http_archive defined at: .cache/bazel/_bazel_root/be2d1fe448dd770f03a597a2a9fa3688/external/bazel_tools/tools/build_defs/repo/http.bzl:355:31: in INFO: Repository rules_cc instantiated at: repositories/coral/pycoral/WORKSPACE:126:14: in .cache/bazel/_bazel_root/be2d1fe448dd770f03a597a2a9fa3688/external/org_tensorflow/tensorflow/workspace1.bzl:34:14: in workspace .cache/bazel/_bazel_root/be2d1fe448dd770f03a597a2a9fa3688/external/com_github_grpc_grpc/bazel/grpc_deps.bzl:158:21: in grpc_deps Repository rule http_archive defined at: .cache/bazel/_bazel_root/be2d1fe448dd770f03a597a2a9fa3688/external/bazel_tools/tools/build_defs/repo/http.bzl:355:31: in ERROR: Analysis of target '//src:_pywrap_coral' failed; build aborted: error loading package '@org_tensorflow//tensorflow': initialization of module 'tensorflow/python/tools/api/generator2/generate_api.bzl' failed INFO: Elapsed time: 1.298s INFO: 0 processes. FAILED: Build did NOT complete successfully (5 packages loaded, 8 targets configured) currently loading: @org_tensorflow//tensorflow Fetching https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/rules_proto/archive/11bf7c25e666dd7ddacbcd4d4c4a9de7a25175f8.tar.gz Fetching https://github.com/bazelbuild/rules_cc/archive/624b5d59dfb45672d4239422fa1e3de1822ee110.tar.gz make: *** [Makefile:152: pybind] Error 1 ```