Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem getting python include path while building tensorflow lite using Bazel #67062

Open
Thunderzen opened this issue May 7, 2024 · 3 comments
Assignees
Labels
comp:lite TF Lite related issues stale This label marks the issue/pr stale - to be closed automatically if no activity stat:awaiting response Status - Awaiting response from author subtype:bazel Bazel related Build_Installation issues TF 2.5 Issues related to TF 2.5 type:build/install Build and install issues

Comments

@Thunderzen
Copy link

Issue type

Build/Install

Have you reproduced the bug with TensorFlow Nightly?

No

Source

source

TensorFlow version

2.5

Custom code

No

OS platform and distribution

No response

Mobile device

No response

Python version

3.10.12

Bazel version

3.7.2

GCC/compiler version

No response

CUDA/cuDNN version

No response

GPU model and memory

No response

Current behavior?

While building tensorflow lite using bazel, I encountered the following errors in the log output. Here is my bazel command:

/c/tensorflow-2.5.0/tflite_build$ bazel build --config=elinux_armhf -c opt --crosstool_top=//toolchain:armv7-toolchain //tensorflow/lite:libtensorflowlite.so

Standalone code to reproduce the issue

NIL

Relevant log output

ERROR: An error occurred during the fetch of repository 'local_execution_config_python':
   Traceback (most recent call last):
        File "/mnt/c/tensorflow-2.5.0/third_party/py/python_configure.bzl", line 212, column 41, in _create_local_python_repository
                python_include = _get_python_include(repository_ctx, python_bin)
        File "/mnt/c/tensorflow-2.5.0/third_party/py/python_configure.bzl", line 152, column 21, in _get_python_include
                result = execute(
        File "/mnt/c/tensorflow-2.5.0/third_party/remote_config/common.bzl", line 219, column 13, in execute
                fail(
Error in fail: Problem getting python include path.
<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
Is the Python binary path set up right? (See ./configure or PYTHON_BIN_PATH.) Is distutils installed?
@google-ml-butler google-ml-butler bot added the type:build/install Build and install issues label May 7, 2024
@Thunderzen
Copy link
Author

These are my default python paths:
INFO: Reading rc options for 'build' from /mnt/c/tensorflow-2.5.0/.tf_configure.bazelrc:
'build' options: --action_env PYTHON_BIN_PATH=/usr/bin/python3 --action_env PYTHON_LIB_PATH=/usr/lib/python3/dist-packages --python_path=/usr/bin/python3

@tilakrayal tilakrayal added TF 2.5 Issues related to TF 2.5 comp:lite TF Lite related issues subtype:bazel Bazel related Build_Installation issues labels May 7, 2024
@tilakrayal
Copy link
Contributor

@Thunderzen,
There are a few more simultaneous issues... If you feel you can make progress on a root cause PR please feel free to submit one that we can review.

As a Temporary fix, could you please try adding python definitions in the {project}/WORKSPACE file, then it might work. and Project can be built successfully.

# bazel_skylib and rules_python are from @org_tensorflow/WORKSPACE.
http_archive(
    name = "bazel_skylib",
    sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506",
    urls = [
        "https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
        "https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
    ],
)

http_archive(
    name = "rules_python",
    sha256 = "9d04041ac92a0985e344235f5d946f71ac543f1b1565f2cdbc9a2aaee8adf55b",
    strip_prefix = "rules_python-0.26.0",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.26.0/rules_python-0.26.0.tar.gz",
)

# Copied from `@org_tensorflow//:WORKSPACE`.
load(
    "@rules_python//python:repositories.bzl",
    "py_repositories",
    "python_register_toolchains",
)
py_repositories()

load(
    "@org_tensorflow//tensorflow/tools/toolchains/python:python_repo.bzl",
    "python_repository",
)
python_repository(name = "python_version_repo")
load("@python_version_repo//:py_version.bzl", "HERMETIC_PYTHON_VERSION")

# Toolchain setup here is to please the TF workspace scripts,
# and we do not use this Python version to build pip packages.
python_register_toolchains(
    name = "python",
    ignore_root_user_error = True,
    python_version = HERMETIC_PYTHON_VERSION,
)

Also tensorflow v2.5 is pretty old, please try to upgrade to the latest tensorflow v2.15 or v2.16. Thank you!

@tilakrayal tilakrayal added the stat:awaiting response Status - Awaiting response from author label May 8, 2024
Copy link

This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you.

@github-actions github-actions bot added the stale This label marks the issue/pr stale - to be closed automatically if no activity label May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:lite TF Lite related issues stale This label marks the issue/pr stale - to be closed automatically if no activity stat:awaiting response Status - Awaiting response from author subtype:bazel Bazel related Build_Installation issues TF 2.5 Issues related to TF 2.5 type:build/install Build and install issues
Projects
None yet
Development

No branches or pull requests

2 participants