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

Errors building Tensorflow from source #59943

Closed
mikcla opened this issue Mar 9, 2023 · 10 comments
Closed

Errors building Tensorflow from source #59943

mikcla opened this issue Mar 9, 2023 · 10 comments
Assignees
Labels
stale This label marks the issue/pr stale - to be closed automatically if no activity stat:awaiting response Status - Awaiting response from author subtype:windows Windows Build/Installation Issues TF 2.11 Issues related to TF 2.11 type:build/install Build and install issues

Comments

@mikcla
Copy link

mikcla commented Mar 9, 2023

Click to expand!

Issue Type

Build/Install

Have you reproduced the bug with TF nightly?

No

Source

source

Tensorflow Version

2.11.0

Custom Code

No

OS Platform and Distribution

Windows 11

Mobile device

No response

Python version

3.10.10

Bazel version

5.3.0

GCC/Compiler version

No response

CUDA/cuDNN version

No response

GPU model and memory

No response

Current Behaviour?

I am trying to build Tensorflow from source, so i can use AVX, AVX2 and so on.

I typed this command, expecting to build Tensorflow with all supported instruction-sets, my pc supports:

bazel build --config=opt --copt=-march=native //tensorflow/tools/pip_package:build_pip_package

Standalone code to reproduce the issue

I get these errors:

ERROR: An error occurred during the fetch of repository 'llvm-project':
   Traceback (most recent call last):
        File "C:/tmp/hn4nqluc/external/llvm-raw/utils/bazel/configure.bzl", line 146, column 25, in _llvm_configure_impl
                _overlay_directories(repository_ctx)
        File "C:/tmp/hn4nqluc/external/llvm-raw/utils/bazel/configure.bzl", line 49, column 13, in _overlay_directories
                fail("Failed to find python3 binary")
Error in fail: Failed to find python3 binary



ERROR: C:/users/micla/code/python/diceml/tensorflow/WORKSPACE:15:14: fetching llvm_configure rule //external:llvm-project: Traceback (most recent call last):
        File "C:/tmp/hn4nqluc/external/llvm-raw/utils/bazel/configure.bzl", line 146, column 25, in _llvm_configure_impl
                _overlay_directories(repository_ctx)
        File "C:/tmp/hn4nqluc/external/llvm-raw/utils/bazel/configure.bzl", line 49, column 13, in _overlay_directories
                fail("Failed to find python3 binary")
Error in fail: Failed to find python3 binary


ERROR: C:/users/micla/code/python/diceml/tensorflow/tensorflow/tools/pip_package/BUILD:276:10: //tensorflow/tools/pip_package:build_pip_package depends on //tensorflow/compiler/mlir/tensorflow:gen_mlir_passthrough_op_py in repository @ which failed to fetch. no such package '@llvm-project//mlir': Failed to find python3 binary


ERROR: Analysis of target '//tensorflow/tools/pip_package:build_pip_package' failed; build aborted: Analysis failed


FAILED: Build did NOT complete successfully (51 packages loaded, 12 targets config\
ured)
    currently loading: tensorflow/lite/tools ... (3 packages)
    Fetching https://storage.googleapis.com/.../flatbuffers/archive/v2.0.6.tar.gz

Relevant log output

INFO: Reading 'startup' options from c:\users\micla\code\python\diceml\tensorflow\.bazelrc: --output_user_root=C:/tmp, --windows_enable_symlinks
INFO: Options provided by the client:
  Inherited 'common' options: --isatty=1 --terminal_columns=84
INFO: Reading rc options for 'build' from c:\users\micla\code\python\diceml\tensorflow\.bazelrc:
  Inherited 'common' options: --experimental_repo_remote_exec
INFO: Options provided by the client:
  'build' options: --python_path=C:/Users/micla/AppData/Local/Microsoft/WindowsApps/python.exe
INFO: Reading rc options for 'build' from c:\users\micla\code\python\diceml\tensorflow\.bazelrc:
  'build' options: --enable_runfiles --define framework_shared_object=true --define tsl_protobuf_header_only=true --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 --experimental_link_static_libraries_once=false --incompatible_enforce_config_setting_visibility
INFO: Reading rc options for 'build' from c:\users\micla\code\python\diceml\tensorflow\.tf_configure.bazelrc:
  'build' options: --action_env PYTHON_BIN_PATH=C:/Users/micla/AppData/Local/Programs/Python/Python310/python.exe --action_env PYTHON_LIB_PATH=C:/Users/micla/AppData/Local/Programs/Python/Python310/lib/site-packages --python_path=C:/Users/micla/AppData/Local/Programs/Python/Python310/python.exe --copt=/d2ReducedOptimizeHugeFunctions --host_copt=/d2ReducedOptimizeHugeFunctions --define=override_eigen_strong_inline=true
INFO: Reading rc options for 'build' from c:\users\micla\code\python\diceml\tensorflow\.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/ir,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/lhlo_to_jitrt,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/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/gpu,tensorflow/core/tfrt/run_handler_thread_pool,tensorflow/core/tfrt/runtime,tensorflow/core/tfrt/saved_model,tensorflow/core/tfrt/graph_executor,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\micla\code\python\diceml\tensorflow\.bazelrc: --output_filter=DONT_MATCH_ANYTHING
INFO: Found applicable config definition build:v2 in file c:\users\micla\code\python\diceml\tensorflow\.bazelrc: --define=tf_api_version=2 --action_env=TF2_BEHAVIOR=1
INFO: Found applicable config definition build:opt in file c:\users\micla\code\python\diceml\tensorflow\.tf_configure.bazelrc: --copt=/arch:AVX2 --host_copt=/arch:AVX2
INFO: Found applicable config definition build:windows in file c:\users\micla\code\python\diceml\tensorflow\.bazelrc: --copt=/W0 --host_copt=/W0 --copt=/Zc:__cplusplus --host_copt=/Zc:__cplusplus --copt=/D_USE_MATH_DEFINES --host_copt=/D_USE_MATH_DEFINES --features=compiler_param_file --copt=/d2ReducedOptimizeHugeFunctions --host_copt=/d2ReducedOptimizeHugeFunctions --cxxopt=/std:c++17 --host_cxxopt=/std:c++17 --config=monolithic --copt=-DWIN32_LEAN_AND_MEAN --host_copt=-DWIN32_LEAN_AND_MEAN --copt=-DNOGDI --host_copt=-DNOGDI --copt=/Zc:preprocessor --host_copt=/Zc: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\micla\code\python\diceml\tensorflow\.bazelrc: --define framework_shared_object=false --define tsl_protobuf_header_only=false --experimental_link_static_libraries_once=false
WARNING: Download from https://storage.googleapis.com/mirror.tensorflow.org/github.com/tensorflow/runtime/archive/85488e9aae621ec5175b94fc5e31e41b7e5e06ac.tar.gz failed: class java.io.FileNotFoundException GET returned 404 Not Found
WARNING: Download from https://storage.googleapis.com/mirror.tensorflow.org/github.com/llvm/llvm-project/archive/65f68812d399930d4af587c7a2333e46f367c5a7.tar.gz failed: class java.io.FileNotFoundException GET returned 404 Not Found
WARNING: Download from https://mirror.bazel.build/github.com/bazelbuild/rules_cc/archive/081771d4a0e9d7d3aa0eed2ef389fa4700dfb23e.tar.gz failed: class java.io.FileNotFoundException GET returned 404 Not Found
INFO: Repository llvm-project instantiated at:
  C:/users/micla/code/python/diceml/tensorflow/WORKSPACE:15:14: in <toplevel>
  C:/users/micla/code/python/diceml/tensorflow/tensorflow/workspace2.bzl:975:21: in workspace
  C:/users/micla/code/python/diceml/tensorflow/tensorflow/workspace2.bzl:539:15: in _tf_repositories
  C:/users/micla/code/python/diceml/tensorflow/third_party/llvm/setup.bzl:22:19: in llvm_setup
Repository rule llvm_configure defined at:
  C:/tmp/hn4nqluc/external/llvm-raw/utils/bazel/configure.bzl:169:33: in <toplevel>
ERROR: An error occurred during the fetch of repository 'llvm-project':
   Traceback (most recent call last):
        File "C:/tmp/hn4nqluc/external/llvm-raw/utils/bazel/configure.bzl", line 146, column 25, in _llvm_configure_impl
                _overlay_directories(repository_ctx)
        File "C:/tmp/hn4nqluc/external/llvm-raw/utils/bazel/configure.bzl", line 49, column 13, in _overlay_directories
                fail("Failed to find python3 binary")
Error in fail: Failed to find python3 binary
ERROR: C:/users/micla/code/python/diceml/tensorflow/WORKSPACE:15:14: fetching llvm_configure rule //external:llvm-project: Traceback (most recent call last):
        File "C:/tmp/hn4nqluc/external/llvm-raw/utils/bazel/configure.bzl", line 146, column 25, in _llvm_configure_impl
                _overlay_directories(repository_ctx)
        File "C:/tmp/hn4nqluc/external/llvm-raw/utils/bazel/configure.bzl", line 49, column 13, in _overlay_directories
                fail("Failed to find python3 binary")
Error in fail: Failed to find python3 binary
INFO: Repository build_bazel_rules_android instantiated at:
  C:/users/micla/code/python/diceml/tensorflow/WORKSPACE:15:14: in <toplevel>
  C:/users/micla/code/python/diceml/tensorflow/tensorflow/workspace2.bzl:975:21: in workspace
  C:/users/micla/code/python/diceml/tensorflow/tensorflow/workspace2.bzl:814:20: in _tf_repositories
  C:/users/micla/code/python/diceml/tensorflow/third_party/repo.bzl:136:21: in tf_http_archive
Repository rule _tf_http_archive defined at:
  C:/users/micla/code/python/diceml/tensorflow/third_party/repo.bzl:89:35: in <toplevel>
INFO: Repository flatbuffers instantiated at:
  C:/users/micla/code/python/diceml/tensorflow/WORKSPACE:15:14: in <toplevel>
  C:/users/micla/code/python/diceml/tensorflow/tensorflow/workspace2.bzl:968:28: in workspace
  C:/users/micla/code/python/diceml/tensorflow/tensorflow/workspace2.bzl:65:16: in _initialize_third_party
  C:/users/micla/code/python/diceml/tensorflow/third_party/flatbuffers/workspace.bzl:6:20: in repo
  C:/users/micla/code/python/diceml/tensorflow/third_party/repo.bzl:136:21: in tf_http_archive
Repository rule _tf_http_archive defined at:
  C:/users/micla/code/python/diceml/tensorflow/third_party/repo.bzl:89:35: in <toplevel>
ERROR: C:/users/micla/code/python/diceml/tensorflow/tensorflow/tools/pip_package/BUILD:276:10: //tensorflow/tools/pip_package:build_pip_package depends on //tensorflow/compiler/mlir/tensorflow:gen_mlir_passthrough_op_py in repository @ which failed to fetch. no such package '@llvm-project//mlir': Failed to find python3 binary
ERROR: Analysis of target '//tensorflow/tools/pip_package:build_pip_package' failed; build aborted: Analysis failed
INFO: Elapsed time: 399.994s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (51 packages loaded, 12 targets config\
ured)
    currently loading: tensorflow/lite/tools ... (3 packages)
    Fetching https://storage.googleapis.com/.../flatbuffers/archive/v2.0.6.tar.gz
@google-ml-butler google-ml-butler bot added the type:build/install Build and install issues label Mar 9, 2023
@SuryanarayanaY
Copy link
Collaborator

Hi @mikcla ,

Thanks for reporting the issues.
Could you please confirm whether you have followed all the instructions mentioned here.

Also the options from .bazelrc file for AVX instructions:

build:native_arch_linux --copt=-march=native
build:avx_win --copt=/arch=AVX
build:avx2_win --copt=/arch=AVX2

The command you have used --copt=-march=native might be for linux only. Could you try the remaining two options.

Also for TF2.11 tested Bazel version is 5.3.0 which some times may raise compatibility issues.Please see tested configurations from here.

@SuryanarayanaY SuryanarayanaY added subtype:windows Windows Build/Installation Issues TF 2.11 Issues related to TF 2.11 stat:awaiting response Status - Awaiting response from author labels Mar 10, 2023
@mikcla
Copy link
Author

mikcla commented Mar 14, 2023

I have follwed the instructions to my best abillty, and i am using TF 2.11.0 and Bazel 5.3.0. And what command should i type? You typed 3.

@google-ml-butler google-ml-butler bot removed the stat:awaiting response Status - Awaiting response from author label Mar 14, 2023
@SuryanarayanaY
Copy link
Collaborator

Did you tried adding --copt=/arch=AVX --copt=/arch=AVX2 to the command ? Please confirm.

@SuryanarayanaY SuryanarayanaY added the stat:awaiting response Status - Awaiting response from author label Mar 14, 2023
@mraunak
Copy link
Contributor

mraunak commented Mar 15, 2023

@mikcla @SuryanarayanaY I was able to run the bazel build --config=opt --copt=-march=native //tensorflow/tools/pip_package:build_pip_package successfully for TF 2.11.0 with Bazel 5.3.0 on Windows 10 and for Python 3.10. I think this error is related to the path/environmental variable setup

@mikcla
Copy link
Author

mikcla commented Mar 15, 2023

@mraunak I think so to, but I don't how to fix this, I have tried to set system variables, change the path in one of the config files and also tried to change the path in cmd. I am using windows 11 btw.

I’m sorry I don't have everything on hand because I kept moving on with my project, so I took some steps back, and ran simply ran pip install. However I’m willing to try to build from source again some time, but want to have something new to try beforehand.

@google-ml-butler google-ml-butler bot removed the stat:awaiting response Status - Awaiting response from author label Mar 15, 2023
@SuryanarayanaY
Copy link
Collaborator

@mikcla ,

From the error log I observed that Python3 library not being detected.This seems issue with some path setting.Also please ensure all the REQUIRED_PACKAGES mentioned in setup.py installed before bazel build.

While installing bazel please ensure all these steps mentioned here were followed correctly or not.As other contributor confirmed that he succeeded the build with same commands of your's it might be mostly related to your environment.

Thanks!

@SuryanarayanaY SuryanarayanaY added the stat:awaiting response Status - Awaiting response from author label Mar 16, 2023
@github-actions
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 Mar 24, 2023
@github-actions
Copy link

This issue was closed because it has been inactive for 7 days since being marked as stale. Please reopen if you'd like to work on this further.

@google-ml-butler
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

@mraunak
Copy link
Contributor

mraunak commented Apr 14, 2023

Hi @mikcla Python path setup, please follow the commands below. To check the path setup of a specific variable if the path set up is correct run sample commands: 'echo %PATH%' or echo %PYTHON_BIN_PATH%

set PATH=path/to/python [e.g. (C:/Python310)]
set PATH=path/to/python/Scripts [e.g. (C:/Python310/Scripts)]
set PYTHON_BIN_PATH=path/to/python_virtualenv/Scripts/python.exe
set PYTHON_LIB_PATH=path/to/python virtualenv/lib/site-packages
set PYTHON_DIRECTORY=path/to/python_virtualenv/Scripts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale This label marks the issue/pr stale - to be closed automatically if no activity stat:awaiting response Status - Awaiting response from author subtype:windows Windows Build/Installation Issues TF 2.11 Issues related to TF 2.11 type:build/install Build and install issues
Projects
None yet
Development

No branches or pull requests

4 participants