首页 > 解决方案 > 在 ubuntu 20.04 上安装 tflite c++

问题描述

我想在我的 ubuntu 20.04 上安装 tflite c++,但我在安装方面遇到了一些问题。我知道我只能通过使用 cmake 或 bazel 来构建它,但不幸的是它们都不适合我。由于 cmake 占用了大量 RAM,因此每次在构建过程中达到 96% 时都会崩溃,并且 bazel 在构建过程中也会出现一些错误。使用此命令后。

bazel build -c opt //tensorflow/lite:libtensorflowlite.so

它给了我这个 错误。我还检查了 numpy 是否可用。我在关注这个视频。任何人都可以将 github 的链接发送给我,其中 tflite c++ 可用于 ubuntu 或任何其他我可以轻松安装的链接。因为我是新来的。您的意见和建议将不胜感激。提前致谢。

这是我得到的错误。

bazel build -c opt //tensorflow/lite:libtensorflowlite.so
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
INFO: Options provided by the client:
  Inherited 'common' options: --isatty=1 --terminal_columns=91
INFO: Reading rc options for 'build' from /home/umer/Downloads/tensorflow-2.4.2/.bazelrc:
  Inherited 'common' options: --experimental_repo_remote_exec
INFO: Reading rc options for 'build' from /home/umer/Downloads/tensorflow-2.4.2/.bazelrc:
  'build' options: --apple_platform_type=macos --define framework_shared_object=true --define open_source_build=true --java_toolchain=//third_party/toolchains/java:tf_java_toolchain --host_java_toolchain=//third_party/toolchains/java:tf_java_toolchain --define=tensorflow_enable_mlir_generated_gpu_kernels=0 --define=use_fast_cpp_protos=true --define=allow_oversize_protos=true --spawn_strategy=standalone -c opt --announce_rc --define=grpc_no_ares=true --noincompatible_remove_legacy_whole_archive --noincompatible_prohibit_aapt1 --enable_platform_specific_config --config=short_logs --config=v2
INFO: Reading rc options for 'build' from /home/umer/Downloads/tensorflow-2.4.2/.tf_configure.bazelrc:
  'build' options: --host_force_python=PY2 --action_env PYTHON_BIN_PATH=/usr/bin/python --action_env PYTHON_LIB_PATH=/usr/local/lib/python2.7/dist-packages --python_path=/usr/bin/python --config=xla --action_env TF_CONFIGURE_IOS=0
INFO: Found applicable config definition build:short_logs in file /home/umer/Downloads/tensorflow-2.4.2/.bazelrc: --output_filter=DONT_MATCH_ANYTHING
INFO: Found applicable config definition build:v2 in file /home/umer/Downloads/tensorflow-2.4.2/.bazelrc: --define=tf_api_version=2 --action_env=TF2_BEHAVIOR=1
INFO: Found applicable config definition build:xla in file /home/umer/Downloads/tensorflow-2.4.2/.bazelrc: --define=with_xla_support=true
INFO: Found applicable config definition build:linux in file /home/umer/Downloads/tensorflow-2.4.2/.bazelrc: --copt=-w --host_copt=-w --define=PREFIX=/usr --define=LIBDIR=$(PREFIX)/lib --define=INCLUDEDIR=$(PREFIX)/include --define=PROTOBUF_INCLUDE_PATH=$(PREFIX)/include --cxxopt=-std=c++14 --host_cxxopt=-std=c++14 --config=dynamic_kernels
INFO: Found applicable config definition build:dynamic_kernels in file /home/umer/Downloads/tensorflow-2.4.2/.bazelrc: --define=dynamic_loaded_kernels=true --copt=-DAUTOLOAD_DYNAMIC_KERNELS
DEBUG: Rule 'io_bazel_rules_go' indicated that a canonical reproducible form can be obtained by modifying arguments shallow_since = "1557349968 -0400"
DEBUG: Repository io_bazel_rules_go instantiated at:
  no stack (--record_rule_instantiation_callstack not enabled)
Repository rule git_repository defined at:
  /home/umer/.cache/bazel/_bazel_umer/ed358c98f40a3a8df15c688cf3579422/external/bazel_tools/tools/build_defs/repo/git.bzl:195:18: in <toplevel>
INFO: Repository local_config_python instantiated at:
  no stack (--record_rule_instantiation_callstack not enabled)
Repository rule python_configure defined at:
  /home/umer/Downloads/tensorflow-2.4.2/third_party/py/python_configure.bzl:294:20: in <toplevel>
ERROR: An error occurred during the fetch of repository 'local_config_python':
   Traceback (most recent call last):
    File "/home/umer/Downloads/tensorflow-2.4.2/third_party/py/python_configure.bzl", line 267
        _create_local_python_repository(<1 more arguments>)
    File "/home/umer/Downloads/tensorflow-2.4.2/third_party/py/python_configure.bzl", line 213, in _create_local_python_repository
        _get_numpy_include(<2 more arguments>)
    File "/home/umer/Downloads/tensorflow-2.4.2/third_party/py/python_configure.bzl", line 187, in _get_numpy_include
        execute(repository_ctx, <3 more arguments>)
    File "/home/umer/Downloads/tensorflow-2.4.2/third_party/remote_config/common.bzl", line 217, in execute
        fail(<1 more arguments>)
Problem getting numpy include path.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named numpy
Is numpy installed?
ERROR: Analysis of target '//tensorflow/lite:libtensorflowlite.so' failed; build aborted: Traceback (most recent call last):
    File "/home/umer/Downloads/tensorflow-2.4.2/third_party/py/python_configure.bzl", line 267
        _create_local_python_repository(<1 more arguments>)
    File "/home/umer/Downloads/tensorflow-2.4.2/third_party/py/python_configure.bzl", line 213, in _create_local_python_repository
        _get_numpy_include(<2 more arguments>)
    File "/home/umer/Downloads/tensorflow-2.4.2/third_party/py/python_configure.bzl", line 187, in _get_numpy_include
        execute(repository_ctx, <3 more arguments>)
    File "/home/umer/Downloads/tensorflow-2.4.2/third_party/remote_config/common.bzl", line 217, in execute
        fail(<1 more arguments>)
Problem getting numpy include path.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named numpy
Is numpy installed?
INFO: Elapsed time: 87.176s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (11 packages loaded, 19 targets configured)
    currently loading: @bazel_tools//tools/jdk
    Fetching @local_execution_config_python; Restarting.
    Fetching @rules_java; fetching
    Fetching @io_bazel_rules_docker; fetching
    Fetching @go_sdk; fetching

标签: c++tensorflowinstallationtensorflow-liteubuntu-20.04

解决方案


推荐阅读