Mich
Mich

Reputation: 3594

Cannot build the tensorflow C++ API in windows

I followed every step on the instructions and it still won't build https://www.tensorflow.org/install/source_windows

  1. I cannot include the CUDA library and include files, because the python script won't recognize 2 comma separated paths during ./configure.py stage It only recognizes the first one I enter, as you can see I entered them in reverse order and it see the first one just fine. Afaik this is a new addition, because the instructions ask for path at different times.

    Please specify the CUDA SDK version you want to use. [Leave empty to default to CUDA 10]:

    Please specify the cuDNN version you want to use. [Leave empty to default to cuDNN 7]:
    
    Please specify the comma-separated list of base paths to look for CUDA libraries and headers. [Leave empty to use the default]: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\include, C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\lib\x64
    
    Could not find any cudart.lib in any subdirectory:
    ''
    'lib64'
    'lib'
    'lib/-linux-gnu'
    'lib/x64'
    'extras/CUPTI/'
    of:
    'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\include'
    Asking for detailed CUDA configuration...
    
    Please specify the CUDA SDK version you want to use. [Leave empty to default to CUDA 10]:
    
    Please specify the cuDNN version you want to use. [Leave empty to default to cuDNN 7]:
    
    Please specify the comma-separated list of base paths to look for CUDA libraries and headers. [Leave empty to use the default]: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\lib\x64 C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\include
    
    Could not find any cuda.h matching version '10' in any subdirectory:
    ''
    'include'
    'include/cuda'
    'include/*-linux-gnu'
    'extras/CUPTI/include'
    'include/cuda/CUPTI'
    of:
    Asking for detailed CUDA configuration...
    

So I have to disable CUDA support Then Im just trying to just build the DLL and I get this mess of errors

> C:\Temp\tensorflow-master>bazel build --config=opt //tensorflow:tensorflow.dll
> WARNING: Ignoring JAVA_HOME, because it must point to a JDK, not a JRE.
> INFO: Options provided by the client:
>   Inherited 'common' options: --isatty=1 --terminal_columns=120
> INFO: Options provided by the client:
>   'build' options: --python_path=C:/ProgramData/Anaconda3/python.exe
> INFO: Reading rc options for 'build' from c:\temp\tensorflow-master\.bazelrc:
>   'build' options: --apple_platform_type=macos --define framework_shared_object=true --define open_source_build=true --define=use_fast_cpp_protos=true --define=allow_oversize_protos=true --spawn_strategy=standalone --strategy=Genrule=standalone -c opt --announce_rc --define=grpc_no_ares=true --define=PREFIX=/usr --define=LIBDIR=$(PREFIX)/lib --define=INCLUDEDIR=$(PREFIX)/include
> INFO: Reading rc options for 'build' from c:\temp\tensorflow-master\.tf_configure.bazelrc:
>   'build' options: --action_env PYTHON_BIN_PATH=C:/ProgramData/Anaconda3/python.exe --action_env PYTHON_LIB_PATH=C:/ProgramData/Anaconda3/lib/site-packages --python_path=C:/ProgramData/Anaconda3/python.exe --config monolithic --copt=-w --host_copt=-w --copt=-DWIN32_LEAN_AND_MEAN --host_copt=-DWIN32_LEAN_AND_MEAN --copt=-DNOGDI --host_copt=-DNOGDI --verbose_failures --distinct_host_configuration=false --action_env TF_CONFIGURE_IOS=0
> INFO: Found applicable config definition build:monolithic in file c:\temp\tensorflow-master\.bazelrc: --define framework_shared_object=false
> INFO: Found applicable config definition build:opt in file c:\temp\tensorflow-master\.tf_configure.bazelrc: --copt=/arch:AVX --define with_default_optimizations=true
> INFO: An error occurred during the fetch of repository 'com_google_protobuf'
> INFO: Call stack for the definition of repository 'com_google_protobuf':
>  - C:/temp/tensorflow-master/tensorflow/workspace.bzl:432:5
>  - C:/temp/tensorflow-master/WORKSPACE:26:1
> ERROR: Skipping '//tensorflow:tensorflow.dll': error loading package 'tensorflow': in C:/temp/tensorflow-master/tensorflow/core/platform/default/build_config.bzl: Encountered error while reading extension file 'protobuf.bzl': no such package '@com_google_protobuf//': Traceback (most recent call last):
>         File "C:/temp/tensorflow-master/third_party/repo.bzl", line 104
>                 _apply_patch(ctx, ctx.attr.patch_file)
>         File "C:/temp/tensorflow-master/third_party/repo.bzl", line 70, in _apply_patch
>                 _wrap_bash_cmd(ctx, patch_command)
>         File "C:/temp/tensorflow-master/third_party/repo.bzl", line 28, in _wrap_bash_cmd
>                 fail("BAZEL_SH environment variable i...")
> BAZEL_SH environment variable is not set
> WARNING: Target pattern parsing failed.
> ERROR: error loading package 'tensorflow': in C:/temp/tensorflow-master/tensorflow/core/platform/default/build_config.bzl: Encountered error while reading extension file 'protobuf.bzl': no such package '@com_google_protobuf//': Traceback (most recent call last):
>         File "C:/temp/tensorflow-master/third_party/repo.bzl", line 104
>                 _apply_patch(ctx, ctx.attr.patch_file)
>         File "C:/temp/tensorflow-master/third_party/repo.bzl", line 70, in _apply_patch
>                 _wrap_bash_cmd(ctx, patch_command)
>         File "C:/temp/tensorflow-master/third_party/repo.bzl", line 28, in _wrap_bash_cmd
>                 fail("BAZEL_SH environment variable i...")
> BAZEL_SH environment variable is not set
> INFO: Elapsed time: 21.498s
> INFO: 0 processes.
> FAILED: Build did NOT complete successfully (0 packages loaded)
>     currently loading: tensorflow

I already added to the top of WORKSPACE file as suggested in one of the issues on github

http_archive(
    name = "io_bazel_rules_docker",
    sha256 = "87fc6a2b128147a0a3039a2fd0b53cc1f2ed5adb8716f50756544a572999ae9a",
    strip_prefix = "rules_docker-0.8.1",
    urls = ["https://github.com/bazelbuild/rules_docker/archive/v0.8.1.tar.gz"],
)

How do I get past these errors?

And why is there such poor support for C++, as far as I know everyone uses tensorflow with C++ to do inference. I can't imagine all the self-driving cars are running on python

Upvotes: 4

Views: 1931

Answers (1)

Mich
Mich

Reputation: 3594

Fixed by running command

c:\msys32\usr\bin\sed -ri "/^\W+sha256 = \"[^\"]+\"\W+$/d" tensorflow/workspace.bzl

Which disables checksum validation completely https://github.com/tensorflow/tensorflow/issues/12979

Then I also needed to do

c:\msys32\usr\bin\pacman.exe -S git patch unzip

and add the BAZEL_SH environment variable c:\msys32\usr\bin\bash.exe

Upvotes: 2

Related Questions