tensorflow / text

Making text a first-class citizen in TensorFlow.
https://www.tensorflow.org/beta/tutorials/tensorflow_text/intro
Apache License 2.0
1.23k stars 344 forks source link

windows 10 build error #623

Open alanpurple opened 3 years ago

alanpurple commented 3 years ago

cygwin mismatch error + bazel build error

ERROR: An error occurred during the fetch of repository 'local_execution_config_python':
   Traceback (most recent call last):
        File "C:/users/alanp/_bazel_alanp/6x5nacvr/external/org_tensorflow/third_party/py/python_configure.bzl", line 210, column 33, in _create_local_python_repository
                python_lib = _get_python_lib(repository_ctx, python_bin)
        File "C:/users/alanp/_bazel_alanp/6x5nacvr/external/org_tensorflow/third_party/py/python_configure.bzl", line 130, column 21, in _get_python_lib
                result = execute(repository_ctx, [python_bin, "-c", cmd])
        File "C:/users/alanp/_bazel_alanp/6x5nacvr/external/org_tensorflow/third_party/remote_config/common.bzl", line 219, column 13, in execute
                fail(
Error in fail: Repository command failed
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
INFO: Repository go_sdk instantiated at:
  C:/users/alanp/repo/tftext/WORKSPACE:78:10: in <toplevel>
  C:/users/alanp/_bazel_alanp/6x5nacvr/external/org_tensorflow/tensorflow/workspace0.bzl:117:20: in workspace
  C:/users/alanp/_bazel_alanp/6x5nacvr/external/com_github_grpc_grpc/bazel/grpc_extra_deps.bzl:36:27: in grpc_extra_deps
  C:/users/alanp/_bazel_alanp/6x5nacvr/external/io_bazel_rules_go/go/toolchain/toolchains.bzl:379:28: in go_register_toolchains
  C:/users/alanp/_bazel_alanp/6x5nacvr/external/io_bazel_rules_go/go/private/sdk.bzl:65:21: in go_download_sdk
Repository rule _go_download_sdk defined at:
  C:/users/alanp/_bazel_alanp/6x5nacvr/external/io_bazel_rules_go/go/private/sdk.bzl:53:35: in <toplevel>
ERROR: Analysis of target '//oss_scripts/pip_package:build_pip_package' failed; build aborted: Repository command failed
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
INFO: Elapsed time: 0.768s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (3 packages loaded, 58 targets configured)
    currently loading: @org_tensorflow_hub//tensorflow_hub
    Fetching ...docker; Cloning 251f6a68b439744094faff800cd029798edf9faa of https://github.com/bazelbuild/rules_docker\
.git
edloper commented 3 years ago

Please check that Python is installed on your machine. If not, then you will need to download it from https://python.org. In the installation be sure to check the option that adds Python to PATH.

If that doesn't work, then a few other solution options are suggested here: https://stackoverflow.com/questions/65348890/python-was-not-found-run-without-arguments-to-install-from-the-microsoft-store

alanpurple commented 3 years ago

@edloper

I checked that "Manage app execution alias" but after applying that, another error came up so I reverted

broken commented 3 years ago

As @edloper pointed out, this looks like an environment setup problem. I suggest following the environment setup instructions for TF: https://www.tensorflow.org/install/source_windows

alanpurple commented 3 years ago

@edloper @broken

I've built tensorflow so many times

you guys answered totally wrong answers

image

edloper commented 3 years ago

@alanpurple You could try editing the file execute method in the tensorflow/third_party/remote_config/common.bzl.oss file, to print each command before it runs. You could then try running that command on the command-line to see if it fails for you there. If it doesn't, then I expect that there's a difference in the environment (e.g., in PATH).

You could also try setting the PYTHON_BIN_PATH environment variable. (Or if it's already set, make sure it points to an appropriate Python binary.)

broken commented 3 years ago

Do you have the same issue building TF too?

alanpurple commented 3 years ago

@broken no, tf build is fine

alanpurple commented 3 years ago

another error

ERROR: An error occurred during the fetch of repository 'local_config_python':
   Traceback (most recent call last):
        File "C:/users/alanp/_bazel_alanp/6x5nacvr/external/org_tensorflow/third_party/py/python_configure.bzl", line 267, column 40, in _python_autoconf_impl
                _create_local_python_repository(repository_ctx)
        File "C:/users/alanp/_bazel_alanp/6x5nacvr/external/org_tensorflow/third_party/py/python_configure.bzl", line 209, column 22, in _create_local_python_repository
                _check_python_bin(repository_ctx, python_bin)
        File "C:/users/alanp/_bazel_alanp/6x5nacvr/external/org_tensorflow/third_party/py/python_configure.bzl", line 145, column 25, in _check_python_bin
                auto_config_fail("--define %s='%s' is not executable. Is it the python binary?" % (
        File "C:/users/alanp/_bazel_alanp/6x5nacvr/external/org_tensorflow/third_party/remote_config/common.bzl", line 12, column 9, in auto_config_fail
                fail("%sConfiguration Error:%s %s\n" % (red, no_color, msg))
Error in fail: Configuration Error: --define PYTHON_BIN_PATH='C:\\Users\\alanp\\anaconda3\\python.exe
C:\\Users\\alanp\\AppData\\Local\\Microsoft\\WindowsApps\\python.exe' is not executable. Is it the python binary?
INFO: Repository go_sdk instantiated at:
  C:/users/alanp/repo/tftext/WORKSPACE:80:10: in <toplevel>
  C:/users/alanp/_bazel_alanp/6x5nacvr/external/org_tensorflow/tensorflow/workspace0.bzl:117:20: in workspace
  C:/users/alanp/_bazel_alanp/6x5nacvr/external/com_github_grpc_grpc/bazel/grpc_extra_deps.bzl:36:27: in grpc_extra_deps
  C:/users/alanp/_bazel_alanp/6x5nacvr/external/io_bazel_rules_go/go/toolchain/toolchains.bzl:379:28: in go_register_toolchains
  C:/users/alanp/_bazel_alanp/6x5nacvr/external/io_bazel_rules_go/go/private/sdk.bzl:65:21: in go_download_sdk
Repository rule _go_download_sdk defined at:
  C:/users/alanp/_bazel_alanp/6x5nacvr/external/io_bazel_rules_go/go/private/sdk.bzl:53:35: in <toplevel>
INFO: Repository 'go_sdk' used the following cache hits instead of downloading the corresponding file.
 * Hash 'ccb694279aab39fe0e70629261f13b0307ee40d2d5e1138ed94738023ab04baa' for https://dl.google.com/go/go1.12.5.windows-amd64.zip
If the definition of 'go_sdk' was updated, verify that the hashes were also updated.
ERROR: Analysis of target '//oss_scripts/pip_package:build_pip_package' failed; build aborted: Configuration Error: --define PYTHON_BIN_PATH='C:\\Users\\alanp\\anaconda3\\python.exe
C:\\Users\\alanp\\AppData\\Local\\Microsoft\\WindowsApps\\python.exe' is not executable. Is it the python binary?

seems to be related to https://github.com/bazelbuild/bazel/issues/12029

broken commented 3 years ago

Yep. That looks like a Bazel issue. Strangely, after asking around, nobody I know has hit this error, so I still suspect it is partially due to your environment.

alanpurple commented 3 years ago

@broken

did anyone of them have same environment as me? conda 4.10.1 python 3.9.4 tensorflow 2.5.0 build from source with cuda 11.3 and cudnn 8.1.0 windows 10 x64 21h1

I have 2 computers with same error

broken commented 3 years ago

I don't know all of the environment setups, but if using conda, bazel uses the global python version. Does this match your local python version?

If they do, you may want to try without conda just to check if the problem is some other odd interaction with the conda environment.

omnesan commented 2 years ago

not using a similar environment as you, but I did run into a similar error issue as you (C:\Users\alanp\AppData\Local\Microsoft\WindowsApps\python.exe' is not executable. Is it the python binary?)

The solution that solved it for me was to specifically use quotations around the path as shown below and use // not \\ as it isn't recognizing it properly. PYTHON_BIN_PATH="C://path//to//python.exe" Referenced from a mediapipe installation guide you can view here

alanpurple commented 2 years ago

@broken @edloper

now 2 path problems are solved, but the next problem remains

path problems were solved by 2 lines $Env:PYTHON_BIN_PATH="C:\Users\alanp\anaconda3\python.exe" $Env:PYTHON_LIB_PATH="C:\Users\alanp\anaconda3\Lib\site-packages" or alternatively I could add to windows environment

but now @local_config_tf problem

INFO: Repository local_config_tf instantiated at:
  D:/repo/tftext/WORKSPACE:105:13: in <toplevel>
Repository rule tf_configure defined at:
  D:/repo/tftext/third_party/tensorflow/tf_configure.bzl:207:31: in <toplevel>
ERROR: An error occurred during the fetch of repository 'local_config_tf':
   Traceback (most recent call last):
        File "D:/repo/tftext/third_party/tensorflow/tf_configure.bzl", line 182, column 46, in _tf_pip_impl
                tf_header_rule = _symlink_genrule_for_dir(
        File "D:/repo/tftext/third_party/tensorflow/tf_configure.bzl", line 154, column 29, in _symlink_genrule_for_dir
                src_dir = _norm_path(src_dir)
        File "D:/repo/tftext/third_party/tensorflow/tf_configure.bzl", line 126, column 12, in _norm_path
                if path[-1] == "/":
Error: index out of range (index is -1, but sequence has 0 elements)
ERROR: D:/repo/tftext/WORKSPACE:105:13: fetching tf_configure rule //external:local_config_tf: Traceback (most recent call last):
        File "D:/repo/tftext/third_party/tensorflow/tf_configure.bzl", line 182, column 46, in _tf_pip_impl
                tf_header_rule = _symlink_genrule_for_dir(
        File "D:/repo/tftext/third_party/tensorflow/tf_configure.bzl", line 154, column 29, in _symlink_genrule_for_dir
                src_dir = _norm_path(src_dir)
        File "D:/repo/tftext/third_party/tensorflow/tf_configure.bzl", line 126, column 12, in _norm_path
                if path[-1] == "/":
Error: index out of range (index is -1, but sequence has 0 elements)
INFO: Repository com_google_absl instantiated at:
  D:/repo/tftext/WORKSPACE:97:14: in <toplevel>
  C:/users/alanp/_bazel_alanp/b4reobeo/external/org_tensorflow/tensorflow/workspace2.bzl:873:28: in workspace
  C:/users/alanp/_bazel_alanp/b4reobeo/external/org_tensorflow/tensorflow/workspace2.bzl:59:9: in _initialize_third_party
  C:/users/alanp/_bazel_alanp/b4reobeo/external/org_tensorflow/third_party/absl/workspace.bzl:39:20: in repo
  C:/users/alanp/_bazel_alanp/b4reobeo/external/org_tensorflow/third_party/repo.bzl:128:21: in tf_http_archive
Repository rule _tf_http_archive defined at:
  C:/users/alanp/_bazel_alanp/b4reobeo/external/org_tensorflow/third_party/repo.bzl:81:35: in <toplevel>
INFO: Repository com_googlesource_code_re2 instantiated at:
  D:/repo/tftext/WORKSPACE:97:14: in <toplevel>
  C:/users/alanp/_bazel_alanp/b4reobeo/external/org_tensorflow/tensorflow/workspace2.bzl:880:21: in workspace
  C:/users/alanp/_bazel_alanp/b4reobeo/external/org_tensorflow/tensorflow/workspace2.bzl:244:20: in _tf_repositories
  C:/users/alanp/_bazel_alanp/b4reobeo/external/org_tensorflow/third_party/repo.bzl:128:21: in tf_http_archive
Repository rule _tf_http_archive defined at:
  C:/users/alanp/_bazel_alanp/b4reobeo/external/org_tensorflow/third_party/repo.bzl:81:35: in <toplevel>
ERROR: D:/repo/tftext/tensorflow_text/core/kernels/BUILD:363:14: //tensorflow_text/core/kernels:fast_wordpiece_tokenizer_model_builder depends on @local_config_tf//:libtensorflow_framework in repository @local_config_tf which failed to fetch. no such package '@local_config_tf//': index out of range (index is -1, but sequence has 0 elements)
ERROR: D:/repo/tftext/tensorflow_text/core/kernels/BUILD:363:14: //tensorflow_text/core/kernels:fast_wordpiece_tokenizer_model_builder depends on @local_config_tf//:tf_header_lib in repository @local_config_tf which failed to fetch. no such package '@local_config_tf//': index out of range (index is -1, but sequence has 0 elements)
ERROR: Analysis of target '//oss_scripts/pip_package:build_pip_package' failed; build aborted:
INFO: Elapsed time: 8.066s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (25 packages loaded, 281 targets configured)
    Fetching @com_google_sentencepiece; Restarting.
    Fetching @icu; fetching
broken commented 2 years ago

Did you run oss_scripts/configure.sh? This error is basically trying to set up the path to TF, but the path is empty. This is set in the configure script.

I also recommend running oss_scripts/prepare_tf_dep.sh as well, as this sets up the downloaded TF to be the same version as what you have currently installed if they are different.

Finally, we don't use cygwin when building on windows, we use the terminal 'Developer Command Prompt for VS 2019', and access bash from it (just type bash in it). You may try that as well if you did run the configure script and it just didn't work correctly in cygwin.

alanpurple commented 2 years ago

@broken

with developer command prompt for vs2019, above problems were solved

additionally I needed to install universal windonws crt sdk, and even after that I've met STL header problems from grpc compiling

external/flatbuffers/grpc/src/compiler/swift_generator.cc(23): fatal error C1083: Cannot open include file: 'map': No such file or directory
external/com_google_protobuf/src\google/protobuf/compiler/java/java_generator.h(40): fatal error C1083: Cannot open include file: 'string': No such file or directory

something like these

I think these are problems related to bazel and visual studio compiler

alanpurple commented 2 years ago

after all, this is caused by "com_googlesource_code_re2' code ( obsolete code )

there are many c2679 errors like

no operator found which takes a right-hand operand of type 'std::_String_view_iterator<_Traits>' (or there is no acceptable conversion)
external/com_googlesource_code_re2/re2/nfa.cc(448): error C2678: binary '==': no operator found which takes a left-hand operand of type 'std::_String_view_iterator<_Traits>' (or there is no acceptable conversion)
        with
        [
            _Traits=std::char_traits<char>
        ]
broken commented 2 years ago

This is a transitive dependency from core TF. It looks like they are at commit https://github.com/google/re2/commit/a276a8c738735a0fe45a6ee590fe2df69bcf4502 which was submitted Apr 8, so this is fairly recent.

Are you still trying to build from the 2.5 branch? Can you try head?

My suspicion is that there are some compile options not getting passed that re2 requires. Recently we switched from maintaining our own .bazelrc, to copying over TF's to stay more closely alligned. This happens in configure.sh (https://github.com/tensorflow/text/blob/master/oss_scripts/configure.sh#L67) and should contain all the required options.

alanpurple commented 2 years ago

@broken tried head of course, with tf 2.9

thanks, I need to try again

DevNim98 commented 2 years ago

Hello @alanpurple, im trying to compile tflite for android on windows for the first time, and im facing the 'local_execution_config_python' error even though i set python bin and lib paths as you posted before, currently using tf 2.9 and python 3.10.4, any advice you can give me?