profile
viewpoint

Ask questionsWindows Bazel build fails when using TF_SYSTEM_LIBS

System information

  • OS Platform and Distribution: Windows 10 Pro
  • TensorFlow installed from: source
  • TensorFlow version: 1.11
  • Python version: 3.5.5
  • Installed using: conda
  • Bazel version: 0.15.1
  • GCC/Compiler version: Visual Studio 14.0
  • CUDA/cuDNN version: 9.0
  • GPU model and memory: NVIDIA GeForce GTX 960

Describe the problem

I can build Tensorflow 1.11 normally using Bazel on Windows, but if I set any TF_SYSTEM_LIBS, then Bazel can't find the necessary headers.

Via setting some options and messing with bazel's copt commandline argument and the CC_OPT_FLAGS environment variable, I was once able to get bazel to find zlib.h, but now I can't figure out what I did to make that happen. When that happened, I got a different error, something about zlib.h being an undeclared dependency.

Provide the exact sequence of commands / steps that you executed before running into the problem

steps that I am running in Git Bash:

export PYTHON_BIN_PATH=C:/Users/nstier/AppData/Local/Continuum/anaconda3/python.exe
export PYTHON_LIB_PATH=C:/Users/nstier/AppData/Local/Continuum/anaconda3/Lib

export TF_CUDA_VERSION=9.0
export TF_CUDNN_VERSION=7
export CUDA_TOOLKIT_PATH="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.0"
export CUDNN_INSTALL_PATH="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.0"

export GCC_HOST_COMPILER_PATH=/usr/bin/gcc
export TF_CUDA_CLANG=0

# zlib/ is symlinked into the tensorflow directory to avoid the error "include path references outside of execution root...." 
export CC_OPT_FLAGS="/arch:AVX /I/c/Users/nstier/tensorflow/ExternalPackages/zlib-1.2.11-t1-VC15.8.1/include"

export TF_CUDA_COMPUTE_CAPABILITIES=6.1

export TF_NEED_CUDA=1
export TF_NEED_JEMALLOC=1
export TF_ENABLE_XLA=0
export TF_NEED_OPENCL=0
export TF_NEED_OPENCL_SYCL=0
export TF_NEED_TENSORRT=0
export TF_NEED_NGRAPH=0

export TF_NEED_GCP=0
export TF_NEED_AWS=0

export TF_NEED_KAFKA=0
export TF_NEED_HDFS=0
export TF_NEED_GDR=0
export TF_NEED_VERBS=0
export TF_NEED_MPI=0

export TF_SET_ANDROID_WORKSPACE=0
export TMP=/tmp
export TF_SYSTEM_LIBS=zlib_archive
export TF_OVERRIDE_EIGEN_STRONG_INLINE=1

bazel build \
  --config=opt \
  --config=cuda \
  --config=monolithic \
  --define=no_tensorflow_py_deps=true \
  --copt=/I/c/Users/nstier/tensorflow/ExternalPackages/zlib-1.2.11-t1-VC15.8.1/include \
  --cxxopt=/I/c/Users/nstier/tensorflow/ExternalPackages/zlib-1.2.11-t1-VC15.8.1/include \
   //tensorflow:libtensorflow_cc.so \
  //tensorflow/tools/pip_package:build_pip_package

Any other info / logs

build log: <pre> Starting local Bazel server and connecting to it... ............. WARNING: The following configs were expanded more than once: [cuda, monolithic]. For repeatable flags, repeats are counted twice anday lead to unexpected behavior. Loading: Loading: 0 packages loaded Loading: 0 packages loaded currently loading: tensorflow/tools/pip_package ... (2 packages) DEBUG: C:/users/nstier/_bazel_nstier/t2qf7f76/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:115:5: Auto-Configuration Warning: 'BAZEL_VC' is not set, start looking for the latest Visual C++ installed. DEBUG: C:/users/nstier/_bazel_nstier/t2qf7f76/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:115:5: Auto-Configuration Warning: Looking for VS%VERSION%COMNTOOLS environment variables, eg. VS140COMNTOOLS DEBUG: C:/users/nstier/_bazel_nstier/t2qf7f76/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:115:5: Auto-Configuration Warning: Visual C++ build tools found at C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
DEBUG: C:/users/nstier/_bazel_nstier/t2qf7f76/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:115:5: Auto-Configuration Warning: 'BAZEL_VC' is not set, start looking for the latest Visual C++ installed. DEBUG: C:/users/nstier/_bazel_nstier/t2qf7f76/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:115:5: Auto-Configuration Warning: Looking for VS%VERSION%COMNTOOLS environment variables, eg. VS140COMNTOOLS DEBUG: C:/users/nstier/_bazel_nstier/t2qf7f76/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:115:5: Auto-Configuration Warning: Visual C++ build tools found at C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
Analyzing: 2 targets (2 packages loaded) Analyzing: 2 targets (150 packages loaded) WARNING: C:/users/nstier/tensorflow/tensorflow/core/BUILD:2464:1: in includes attribute of cc_library rule //tensorflow/core:framewo_internal_headers_lib: '../../external/com_google_absl' resolves to 'external/com_google_absl' not below the relative path of its paage 'tensorflow/core'. This will be an error in the future. Since this rule was created by the macro 'cc_header_only_library', the eor might have been caused by the macro implementation in C:/users/nstier/tensorflow/tensorflow/tensorflow.bzl:1373:20 WARNING: C:/users/nstier/tensorflow/tensorflow/core/BUILD:2549:1: in includes attribute of cc_library rule //tensorflow/core:framewo_headers_lib: '../../external/com_google_absl' resolves to 'external/com_google_absl' not below the relative path of its package 'teorflow/core'. This will be an error in the future. Since this rule was created by the macro 'cc_header_only_library', the error mighhave been caused by the macro implementation in C:/users/nstier/tensorflow/tensorflow/tensorflow.bzl:1373:20 WARNING: C:/users/nstier/_bazel_nstier/t2qf7f76/external/grpc/BUILD:1992:1: in srcs attribute of cc_library rule @grpc//:grpc_nanopbplease do not import '@grpc//third_party/nanopb:pb_common.c' directly. You should either move the file to this package or depend on appropriate rule there. Since this rule was created by the macro 'grpc_generate_one_off_targets', the error might have been caused the macro implementation in C:/users/nstier/_bazel_nstier/t2qf7f76/external/grpc/bazel/grpc_build_system.bzl:172:12 WARNING: C:/users/nstier/_bazel_nstier/t2qf7f76/external/grpc/BUILD:1992:1: in srcs attribute of cc_library rule @grpc//:grpc_nanopbplease do not import '@grpc//third_party/nanopb:pb_decode.c' directly. You should either move the file to this package or depend on appropriate rule there. Since this rule was created by the macro 'grpc_generate_one_off_targets', the error might have been caused the macro implementation in C:/users/nstier/_bazel_nstier/t2qf7f76/external/grpc/bazel/grpc_build_system.bzl:172:12 WARNING: C:/users/nstier/_bazel_nstier/t2qf7f76/external/grpc/BUILD:1992:1: in srcs attribute of cc_library rule @grpc//:grpc_nanopbplease do not import '@grpc//third_party/nanopb:pb_encode.c' directly. You should either move the file to this package or depend on appropriate rule there. Since this rule was created by the macro 'grpc_generate_one_off_targets', the error might have been caused the macro implementation in C:/users/nstier/_bazel_nstier/t2qf7f76/external/grpc/bazel/grpc_build_system.bzl:172:12 WARNING: C:/users/nstier/tensorflow/tensorflow/core/BUILD:2563:1: in includes attribute of cc_library rule //tensorflow/core:stream_ecutor_headers_lib: '../../external/com_google_absl' resolves to 'external/com_google_absl' not below the relative path of its packa 'tensorflow/core'. This will be an error in the future. Since this rule was created by the macro 'cc_header_only_library', the erromight have been caused by the macro implementation in C:/users/nstier/tensorflow/tensorflow/tensorflow.bzl:1373:20 WARNING: C:/users/nstier/tensorflow/tensorflow/contrib/learn/BUILD:17:1: in py_library rule //tensorflow/contrib/learn:learn: target//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:exporter': No longer supported. itch to SavedModel immediately. WARNING: C:/users/nstier/tensorflow/tensorflow/contrib/learn/BUILD:17:1: in py_library rule //tensorflow/contrib/learn:learn: target//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:gc': No longer supported. Switcho SavedModel immediately. WARNING: C:/users/nstier/tensorflow/tensorflow/contrib/timeseries/python/timeseries/BUILD:354:1: in py_library rule //tensorflow/conib/timeseries/python/timeseries:ar_model: target '//tensorflow/contrib/timeseries/python/timeseries:ar_model' depends on deprecated rget '//tensorflow/contrib/distributions:distributions_py': TensorFlow Distributions has migrated to TensorFlow Probability (https:/ithub.com/tensorflow/probability). Deprecated copies remaining in tf.contrib.distributions are unmaintained, unsupported, and will bremoved by late 2018. You should update all usage of tf.contrib.distributions to tfp.distributions. WARNING: C:/users/nstier/tensorflow/tensorflow/contrib/timeseries/python/timeseries/state_space_models/BUILD:73:1: in py_library rul//tensorflow/contrib/timeseries/python/timeseries/state_space_models:kalman_filter: target '//tensorflow/contrib/timeseries/python/teseries/state_space_models:kalman_filter' depends on deprecated target '//tensorflow/contrib/distributions:distributions_py': Tensorow Distributions has migrated to TensorFlow Probability (https://github.com/tensorflow/probability). Deprecated copies remaining in .contrib.distributions are unmaintained, unsupported, and will be removed by late 2018. You should update all usage of tf.contrib.dtributions to tfp.distributions. WARNING: C:/users/nstier/tensorflow/tensorflow/contrib/timeseries/python/timeseries/state_space_models/BUILD:230:1: in py_library ru //tensorflow/contrib/timeseries/python/timeseries/state_space_models:filtering_postprocessor: target '//tensorflow/contrib/timeseri/python/timeseries/state_space_models:filtering_postprocessor' depends on deprecated target '//tensorflow/contrib/distributions:distbutions_py': TensorFlow Distributions has migrated to TensorFlow Probability (https://github.com/tensorflow/probability). Deprecatedopies remaining in tf.contrib.distributions are unmaintained, unsupported, and will be removed by late 2018. You should update all uge of tf.contrib.distributions to tfp.distributions. WARNING: C:/users/nstier/tensorflow/tensorflow/contrib/seq2seq/BUILD:23:1: in py_library rule //tensorflow/contrib/seq2seq:seq2seq_p target '//tensorflow/contrib/seq2seq:seq2seq_py' depends on deprecated target '//tensorflow/contrib/distributions:distributions_py'TensorFlow Distributions has migrated to TensorFlow Probability (https://github.com/tensorflow/probability). Deprecated copies remaing in tf.contrib.distributions are unmaintained, unsupported, and will be removed by late 2018. You should update all usage of tf.ctrib.distributions to tfp.distributions. WARNING: C:/users/nstier/tensorflow/tensorflow/contrib/bayesflow/BUILD:17:1: in py_library rule //tensorflow/contrib/bayesflow:bayesow_py: target '//tensorflow/contrib/bayesflow:bayesflow_py' depends on deprecated target '//tensorflow/contrib/distributions:distribions_py': TensorFlow Distributions has migrated to TensorFlow Probability (https://github.com/tensorflow/probability). Deprecated coes remaining in tf.contrib.distributions are unmaintained, unsupported, and will be removed by late 2018. You should update all usagof tf.contrib.distributions to tfp.distributions. WARNING: C:/users/nstier/tensorflow/tensorflow/contrib/BUILD:13:1: in py_library rule //tensorflow/contrib:contrib_py: target '//tenrflow/contrib:contrib_py' depends on deprecated target '//tensorflow/contrib/distributions:distributions_py': TensorFlow Distributio has migrated to TensorFlow Probability (https://github.com/tensorflow/probability). Deprecated copies remaining in tf.contrib.distrutions are unmaintained, unsupported, and will be removed by late 2018. You should update all usage of tf.contrib.distributions totfp.distributions`. INFO: Analysed 2 targets (297 packages loaded). INFO: Found 2 targets... Building: no action [1 / 8] [-----] BazelWorkspaceStatusAction stable-status.txt <b>ERROR: C:/users/nstier/_bazel_nstier/t2qf7f76/external/grpc/BUILD:1443:1: C++ compilation of rule '@grpc//:grpc_transport_chttp2' faed (Exit 2): msvc_wrapper_for_nvcc.bat failed: error executing command cd C:/users/nstier/_bazel_nstier/t2qf7f76/execroot/org_tensorflow SET CUDA_TOOLKIT_PATH=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.0 SET CUDNN_INSTALL_PATH=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.0 SET INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VATLMFC\INCLUDE;C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\ilude\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\shared;C:\Program Files (x86)\Windows Kits\10\include\10.0.17134\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt; SET LIB=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LMFC\LIB\amd64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\l\um\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\um\x64; SET PATH=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64;C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319;C:\Proam Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools;C:\Programiles (x86)\Windows Kits\10\bin\x64;C:\Program Files (x86)\Windows Kits\10\bin\x86;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.\bin\NETFX 4.6.1 Tools\x64;;C:\WINDOWS\system32 SET PWD=/proc/self/cwd SET PYTHON_BIN_PATH=C:/Users/nstier/AppData/Local/Continuum/anaconda3/python.exe SET PYTHON_LIB_PATH=C:/Users/nstier/AppData/Local/Continuum/anaconda3/Lib SET TEMP=C:\Users\nstier\AppData\Local\Temp SET TF_CUDA_CLANG=0 SET TF_CUDA_COMPUTE_CAPABILITIES=6.1 SET TF_CUDA_VERSION=9.0 SET TF_CUDNN_VERSION=7 SET TF_NEED_CUDA=1 SET TF_NEED_OPENCL_SYCL=0 SET TF_SYSTEM_LIBS=zlib_archive SET TMP=C:\Users\nstier\AppData\Local\Temp external/local_config_cuda/crosstool/windows/msvc_wrapper_for_nvcc.bat /nologo /DCOMPILER_MSVC /DNOMINMAX /D_WIN32_WINNT=0x0600 /DRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS /bigobj /Zm500 /J /Gy /GF /EHsc /wd4351wd4291 /wd4250 /wd4996 /Iexternal/grpc /Ibazel-out/x64_windows-opt/genfiles/external/grpc /Iexternal/bazel_tools /Ibazel-out/x64_winws-opt/genfiles/external/bazel_tools /Iexternal/zlib_archive /Ibazel-out/x64_windows-opt/genfiles/external/zlib_archive /Iexternal/gc/include /Ibazel-out/x64_windows-opt/genfiles/external/grpc/include /Ibazel-out/x64_windows-opt/bin/external/grpc/include /DGRPC_AR=0 /showIncludes /MD /O2 /DNDEBUG -w /arch:AVX /I/c/Users/nstier/tensorflow/ExternalPackages/zlib-1.2.11-t1-VC15.8.1/include /I/c/Uss/nstier/tensorflow/ExternalPackages/zlib-1.2.11-t1-VC15.8.1/include /I/c/Users/nstier/tensorflow/ExternalPackages/zlib-1.2.11-t1-VC.8.1/include /Fobazel-out/x64_windows-opt/bin/external/grpc/_objs/grpc_transport_chttp2/hpack_parser.o /c external/grpc/src/core/extransport/chttp2/transport/hpack_parser.cc external/grpc\src/core/lib/compression/stream_compression.h(27): fatal error C1083: Cannot open include file: 'zlib.h': No such file or directory </b> INFO: Elapsed time: 33.850s, Critical Path: 3.71s INFO: 0 processes. FAILED: Build did NOT complete successfully FAILED: Build did NOT complete successfully </pre> Any ideas?

This line from the logs looks interesting: "set INCLUDE=...". Not sure how to get the directories that I want into that list. And if I manage to do that, I might end up with the "undeclared dependency error."

tensorflow/tensorflow

Answer questions gunan

I will close the issue. The last two comments are unrelated to the original issue, so please file new issues for them.

There may already be issues for these, but please keep in mind that I have 80+ issues assigned to me, and I am just back from holiday break. So it may take some time for me to get to all the issues.

useful!

Related questions

Error occurred when finalizing GeneratorDataset iterator
ModuleNotFoundError: No module named 'tensorflow.contrib'
ModuleNotFoundError: No module named 'tensorflow.contrib' hot 4
When importing TensorFlow, error loading Hadoop hot 4
The flag 'log_dir' is defined twice. hot 3
[TF 2.0] Dataset has no attribute 'make_one_shot_iterator' hot 3
Lossy conversion from float32 to uint8. Range [0, 1]. Convert image to uint8 prior to saving to suppress this warning. hot 3
TF2.0 AutoGraph issue hot 3
Error loading tensorflow hot 3
AttributeError: module 'tensorflow' has no attribute 'set_random_seed' hot 3
No tf.lite.experimental.nn.bidirectional_dynamic_rnn ops is finded hot 3
Incorrect Error TypeError: padded_batch() missing 1 required positional argument: &#39;padded_shapes&#39; hot 3
tensorflow2.0 detected 'xla_gpu' , but 'gpu' expected hot 2
Using tensorflow gpu 2.1 with Cuda 10.2 hot 2
Restoring Keras model fails inside a distribution strategy scope hot 2
Github User Rank List