Unable to build TFLite for Windows 10

Hi,

I’ve been trying to build TensorflowLite with XNNPack support for Windows 10 using these two sources:

My environment is composed by:

  • Windows 10
  • Python 3.9.5 (using anaconda virtual environment)
  • Bazel release 5.0.0
  • msys2 release 20220128
  • Tensorflow release 2.8.0

I did all the steps successfully until the moment I need to build tensorflow:

bazel build -c opt --define tflite_with_xnnpack=true //tensorflow/lite/c:tensorflowlite_c.dll

At some point the build stops and outputs the following error:

(tensorflow_xnnpack_py395) C:\Users\cesar.gouveia\Projects\PlayWithTFLite\tensorflow-2.8.0>bazel build -c opt --define tflite_with_xnnpack=true //tensorflow/lite/c:tensorflowlite_c.dll
WARNING: Running Bazel server needs to be killed, because the startup options are different.
Starting local Bazel server and connecting to it...
WARNING: Option 'java_toolchain' is deprecated
WARNING: Option 'host_java_toolchain' is deprecated
INFO: Options provided by the client:
  Inherited 'common' options: --isatty=1 --terminal_columns=120
INFO: Reading rc options for 'build' from c:\users\cesar.gouveia\projects\playwithtflite\tensorflow-2.8.0\.bazelrc:
  Inherited 'common' options: --experimental_repo_remote_exec
INFO: Options provided by the client:
  'build' options: --python_path=C:/Users/cesar.gouveia/Anaconda3/envs/tensorflow_xnnpack_py395/python.exe
INFO: Reading rc options for 'build' from c:\users\cesar.gouveia\projects\playwithtflite\tensorflow-2.8.0\.bazelrc:
  'build' options: --define framework_shared_object=true --java_toolchain=@tf_toolchains//toolchains/java:tf_java_toolchain --host_java_toolchain=@tf_toolchains//toolchains/java:tf_java_toolchain --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 --enable_platform_specific_config --define=with_xla_support=true --config=short_logs --config=v2 --define=no_aws_support=true --define=no_hdfs_support=true --experimental_cc_shared_library
INFO: Reading rc options for 'build' from c:\users\cesar.gouveia\projects\playwithtflite\tensorflow-2.8.0\.tf_configure.bazelrc:
  'build' options: --action_env PYTHON_BIN_PATH=C:/Users/cesar.gouveia/Anaconda3/envs/tensorflow_xnnpack_py395/python.exe --action_env PYTHON_LIB_PATH=C:/Users/cesar.gouveia/Anaconda3/envs/tensorflow_xnnpack_py395/lib/site-packages --python_path=C:/Users/cesar.gouveia/Anaconda3/envs/tensorflow_xnnpack_py395/python.exe --copt=/d2ReducedOptimizeHugeFunctions --host_copt=/d2ReducedOptimizeHugeFunctions --define=override_eigen_strong_inline=true
INFO: Reading rc options for 'build' from c:\users\cesar.gouveia\projects\playwithtflite\tensorflow-2.8.0\.bazelrc:
  'build' options: --deleted_packages=tensorflow/compiler/mlir/tfrt,tensorflow/compiler/mlir/tfrt/benchmarks,tensorflow/compiler/mlir/tfrt/jit/python_binding,tensorflow/compiler/mlir/tfrt/jit/transforms,tensorflow/compiler/mlir/tfrt/python_tests,tensorflow/compiler/mlir/tfrt/tests,tensorflow/compiler/mlir/tfrt/tests/analysis,tensorflow/compiler/mlir/tfrt/tests/jit,tensorflow/compiler/mlir/tfrt/tests/lhlo_to_tfrt,tensorflow/compiler/mlir/tfrt/tests/tf_to_corert,tensorflow/compiler/mlir/tfrt/tests/tf_to_tfrt_data,tensorflow/compiler/mlir/tfrt/tests/saved_model,tensorflow/compiler/mlir/tfrt/transforms/lhlo_gpu_to_tfrt_gpu,tensorflow/core/runtime_fallback,tensorflow/core/runtime_fallback/conversion,tensorflow/core/runtime_fallback/kernel,tensorflow/core/runtime_fallback/opdefs,tensorflow/core/runtime_fallback/runtime,tensorflow/core/runtime_fallback/util,tensorflow/core/tfrt/common,tensorflow/core/tfrt/eager,tensorflow/core/tfrt/eager/backends/cpu,tensorflow/core/tfrt/eager/backends/gpu,tensorflow/core/tfrt/eager/core_runtime,tensorflow/core/tfrt/eager/cpp_tests/core_runtime,tensorflow/core/tfrt/fallback,tensorflow/core/tfrt/gpu,tensorflow/core/tfrt/run_handler_thread_pool,tensorflow/core/tfrt/runtime,tensorflow/core/tfrt/saved_model,tensorflow/core/tfrt/saved_model/tests,tensorflow/core/tfrt/tpu,tensorflow/core/tfrt/utils
INFO: Found applicable config definition build:short_logs in file c:\users\cesar.gouveia\projects\playwithtflite\tensorflow-2.8.0\.bazelrc: --output_filter=DONT_MATCH_ANYTHING
INFO: Found applicable config definition build:v2 in file c:\users\cesar.gouveia\projects\playwithtflite\tensorflow-2.8.0\.bazelrc: --define=tf_api_version=2 --action_env=TF2_BEHAVIOR=1
INFO: Found applicable config definition build:windows in file c:\users\cesar.gouveia\projects\playwithtflite\tensorflow-2.8.0\.bazelrc: --copt=/W0 --copt=/D_USE_MATH_DEFINES --host_copt=/D_USE_MATH_DEFINES --cxxopt=/std:c++14 --host_cxxopt=/std:c++14 --config=monolithic --copt=-DWIN32_LEAN_AND_MEAN --host_copt=-DWIN32_LEAN_AND_MEAN --copt=-DNOGDI --host_copt=-DNOGDI --copt=/experimental:preprocessor --host_copt=/experimental:preprocessor --linkopt=/DEBUG --host_linkopt=/DEBUG --linkopt=/OPT:REF --host_linkopt=/OPT:REF --linkopt=/OPT:ICF --host_linkopt=/OPT:ICF --verbose_failures --features=compiler_param_file --distinct_host_configuration=false
INFO: Found applicable config definition build:monolithic in file c:\users\cesar.gouveia\projects\playwithtflite\tensorflow-2.8.0\.bazelrc: --define framework_shared_object=false
INFO: Repository io_bazel_rules_docker instantiated at:
  C:/users/cesar.gouveia/projects/playwithtflite/tensorflow-2.8.0/WORKSPACE:23:14: in <toplevel>
  C:/users/cesar.gouveia/projects/playwithtflite/tensorflow-2.8.0/tensorflow/workspace0.bzl:108:34: in workspace
  C:/users/cesar.gouveia/_bazel_cesar.gouveia/n2zd2wih/external/bazel_toolchains/repositories/repositories.bzl:35:23: in repositories
Repository rule git_repository defined at:
  C:/users/cesar.gouveia/_bazel_cesar.gouveia/n2zd2wih/external/bazel_tools/tools/build_defs/repo/git.bzl:199:33: in <toplevel>
ERROR: An error occurred during the fetch of repository 'io_bazel_rules_docker':
   Traceback (most recent call last):
        File "C:/users/cesar.gouveia/_bazel_cesar.gouveia/n2zd2wih/external/bazel_tools/tools/build_defs/repo/git.bzl", line 181, column 30, in _git_repository_implementation
                update = _clone_or_update(ctx)
        File "C:/users/cesar.gouveia/_bazel_cesar.gouveia/n2zd2wih/external/bazel_tools/tools/build_defs/repo/git.bzl", line 36, column 20, in _clone_or_update
                git_ = git_repo(ctx, directory)
        File "C:/users/cesar.gouveia/_bazel_cesar.gouveia/n2zd2wih/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 91, column 12, in git_repo
                _update(ctx, git_repo)
        File "C:/users/cesar.gouveia/_bazel_cesar.gouveia/n2zd2wih/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 103, column 10, in _update
                fetch(ctx, git_repo)
        File "C:/users/cesar.gouveia/_bazel_cesar.gouveia/n2zd2wih/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 136, column 13, in fetch
                _git(
        File "C:/users/cesar.gouveia/_bazel_cesar.gouveia/n2zd2wih/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 169, column 15, in _git
                _error(ctx.name, start + list(args), st.stderr)
        File "C:/users/cesar.gouveia/_bazel_cesar.gouveia/n2zd2wih/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 190, column 9, in _error
                fail("error running '%s' while working with @%s:\n%s" % (command_text, name, stderr))
Error in fail: error running 'git fetch origin refs/heads/*:refs/remotes/origin/* refs/tags/*:refs/tags/*' while working with @io_bazel_rules_docker:
BUG: run-command.c:521: disabling cancellation: Invalid argument
      0 [main] git 889 cygwin_exception::open_stackdumpfile: Dumping stack trace to git.exe.stackdump
ERROR: C:/users/cesar.gouveia/projects/playwithtflite/tensorflow-2.8.0/WORKSPACE:23:14: fetching git_repository rule //external:io_bazel_rules_docker: Traceback (most recent call last):
        File "C:/users/cesar.gouveia/_bazel_cesar.gouveia/n2zd2wih/external/bazel_tools/tools/build_defs/repo/git.bzl", line 181, column 30, in _git_repository_implementation
                update = _clone_or_update(ctx)
        File "C:/users/cesar.gouveia/_bazel_cesar.gouveia/n2zd2wih/external/bazel_tools/tools/build_defs/repo/git.bzl", line 36, column 20, in _clone_or_update
                git_ = git_repo(ctx, directory)
        File "C:/users/cesar.gouveia/_bazel_cesar.gouveia/n2zd2wih/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 91, column 12, in git_repo
                _update(ctx, git_repo)
        File "C:/users/cesar.gouveia/_bazel_cesar.gouveia/n2zd2wih/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 103, column 10, in _update
                fetch(ctx, git_repo)
        File "C:/users/cesar.gouveia/_bazel_cesar.gouveia/n2zd2wih/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 136, column 13, in fetch
                _git(
        File "C:/users/cesar.gouveia/_bazel_cesar.gouveia/n2zd2wih/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 169, column 15, in _git
                _error(ctx.name, start + list(args), st.stderr)
        File "C:/users/cesar.gouveia/_bazel_cesar.gouveia/n2zd2wih/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 190, column 9, in _error
                fail("error running '%s' while working with @%s:\n%s" % (command_text, name, stderr))
Error in fail: error running 'git fetch origin refs/heads/*:refs/remotes/origin/* refs/tags/*:refs/tags/*' while working with @io_bazel_rules_docker:
BUG: run-command.c:521: disabling cancellation: Invalid argument
      0 [main] git 889 cygwin_exception::open_stackdumpfile: Dumping stack trace to git.exe.stackdump
INFO: Repository go_sdk instantiated at:
  C:/users/cesar.gouveia/projects/playwithtflite/tensorflow-2.8.0/WORKSPACE:23:14: in <toplevel>
  C:/users/cesar.gouveia/projects/playwithtflite/tensorflow-2.8.0/tensorflow/workspace0.bzl:120:20: in workspace
  C:/users/cesar.gouveia/_bazel_cesar.gouveia/n2zd2wih/external/com_github_grpc_grpc/bazel/grpc_extra_deps.bzl:36:27: in grpc_extra_deps
  C:/users/cesar.gouveia/_bazel_cesar.gouveia/n2zd2wih/external/io_bazel_rules_go/go/toolchain/toolchains.bzl:379:28: in go_register_toolchains
  C:/users/cesar.gouveia/_bazel_cesar.gouveia/n2zd2wih/external/io_bazel_rules_go/go/private/sdk.bzl:65:21: in go_download_sdk
Repository rule _go_download_sdk defined at:
  C:/users/cesar.gouveia/_bazel_cesar.gouveia/n2zd2wih/external/io_bazel_rules_go/go/private/sdk.bzl:53:35: in <toplevel>
ERROR: Analysis of target '//tensorflow/lite/c:tensorflowlite_c.dll' failed; build aborted: error running 'git fetch origin refs/heads/*:refs/remotes/origin/* refs/tags/*:refs/tags/*' while working with @io_bazel_rules_docker:
BUG: run-command.c:521: disabling cancellation: Invalid argument
      0 [main] git 889 cygwin_exception::open_stackdumpfile: Dumping stack trace to git.exe.stackdump
INFO: Elapsed time: 6.163s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (33 packages loaded, 11 targets configured)
    Fetching https://dl.google.com/go/go1.12.5.windows-amd64.zip; 8,839,104B

I tried to run the script using an administrator cmd line, tried using another version of tensorflow / bazel (2.4.4) but neither of the attempts was successful.

Anybody has a solution to this? Or even an ideia that I could test?

Thanks,
César.

HI,

Did you find an answer ?

Hi @GosuPaper , unfortunately no response at all from this forum…