Skip to content

Can't compile tensorflow 2.19.1 on riscv #102159

@Sherlockzhangjinge

Description

@Sherlockzhangjinge

Issue type

Build/Install

Have you reproduced the bug with TensorFlow Nightly?

No

Source

source

TensorFlow version

tf 2.19.1

Custom code

Yes

OS platform and distribution

EulixOS 12.3.1-33.eos30

Mobile device

No response

Python version

3.11.6

Bazel version

2.19.1

GCC/compiler version

gcc (GCC) 12.3.1 (EulixOS 12.3.1-33.eos30)

CUDA/cuDNN version

No

GPU model and memory

No

Current behavior?

I am trying to compile tf 2.19.1 on riscv64. to add support and let bazel build tf with the python on riscv, I create a fold :third_party/python_riscv_reposity which contains BUILD.bazel ,WORKSPACE and riscv64_py_cc_toolchain.bzl. The detail comments is droped below.And I register them in WORKSPACE
local_repository(
name ="python_riscv64-unknown-linux-gnu",
path = "third_party/python_riscv64_toolchain",
)
register_toolchains(
"@python_riscv64-unknown-linux-gnu//:python_riscv64_toolchain",
"@python_riscv64-unknown-linux-gnu//:riscv64_py_cc_toolchain",
)

Now I meet:
ERROR: /root/.cache/bazel/_bazel_root/7b20b9b6ea80f6f214c7e8b22473e299/external/rules_python/python/cc/BUILD.bazel:15:22: in current_py_cc_headers rule @rules_python//python/cc:current_py_cc_headers:
Traceback (most recent call last):
File "/root/.cache/bazel/_bazel_root/7b20b9b6ea80f6f214c7e8b22473e299/external/rules_python/python/private/current_py_cc_headers.bzl", line 21, column 27, in _current_py_cc_headers_impl
return py_cc_toolchain.headers.providers_map.values()
Error: <target @python_riscv64-unknown-linux-gnu//:python_headers> (rule 'cc_library') doesn't have provider 'headers'
ERROR: /root/.cache/bazel/_bazel_root/7b20b9b6ea80f6f214c7e8b22473e299/external/rules_python/python/cc/BUILD.bazel:15:22: Analysis of target '@rules_python//python/cc:current_py_cc_headers' failed
ERROR: Analysis of target '//tensorflow/tools/pip_package:wheel' failed; build aborted:

How can I solve it?

Standalone code to reproduce the issue

WORKSPACE 
workspace(name = "python_riscv64_toolchain_repo")

BUILD.bazel 
load("@rules_python//python:defs.bzl", "py_runtime", "py_runtime_pair")
load("riscv64_py_cc_toolchain.bzl", "riscv64_py_cc_toolchain_rule")

package(default_visibility = ["//visibility:public"])

cc_library(
    name = "python_headers",
    srcs=[],
    hdrs = glob(["python3.11/*.h"]),
    includes = ["python3.11"],
    visibility = ["//visibility:public"],
)

filegroup(
    name = "libpython",
    srcs = ["libpython3.11.so"],
)

filegroup(
    name = "python3",
    srcs = ["bin/python"],
)

py_runtime(
    name = "riscv64_py_runtime",
    interpreter_path = "/AI/zjg/python/venv11/bin/python",
    python_version = "PY3",
    visibility = ["//visibility:public"],
)

py_runtime_pair(
    name = "riscv64_py_runtime_pair",
    py3_runtime = ":riscv64_py_runtime",
    visibility = ["//visibility:public"],
)

toolchain(
    name = "python_riscv64_toolchain",
    toolchain_type = "@rules_python//python:toolchain_type",
    toolchain = ":riscv64_py_runtime_pair",
    visibility = ["//visibility:public"],
)
riscv64_py_cc_toolchain_rule(
    name = "riscv64_py_cc_impl",
    python_includes = ["python3.11"],
    python_headers = [":python_headers"],
)

toolchain(
    name = "riscv64_py_cc_toolchain",
    toolchain_type = "@rules_python//python/cc:toolchain_type",
    toolchain = ":riscv64_py_cc_impl",
    visibility = ["//visibility:public"],
)



riscv64_py_cc_toolchain.bzl

def _riscv64_py_cc_toolchain_impl(ctx):
    py_cc = ctx.attr.python_headers[0]
    return platform_common.ToolchainInfo(
#        py_cc_toolchain = ctx.attr.python_headers,
        py_cc_toolchain = py_cc,
        python_headers = ctx.attr.python_headers,
        python_includes = ctx.attr.python_includes,
    )

riscv64_py_cc_toolchain_rule = rule(
    implementation = _riscv64_py_cc_toolchain_impl,
    attrs = {
        "python_includes": attr.string_list(),
        "python_headers": attr.label_list(allow_files=False),
    },
)

Relevant log output

No

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions