Skip to content

Unable to build tensorflow for Java in Windows #9971

Closed

Description

@nectario

As many may have this problem, I am unable to build tensorflow for Java in Windows. I need to build tensorflow for Java with GPU support in Windows. I followed all the directions specified, and I get the following error message:

Thank you!

$ bazel build --config opt //tensorflow/java:tensorflow //tensorflow/java:libtensorflow_jni
ERROR: C:/development/projects/tensorflow/tensorflow/java/BUILD:142:1: error loading package 'tensorflow/java/src/main/native': Encountered error while reading extension file 'cuda/build_defs.bzl': no such package '@local_config_cuda//cuda': Traceback (most recent call last):
File "C:/development/projects/tensorflow/third_party/gpus/cuda_configure.bzl", line 958
_create_cuda_repository(repository_ctx)
File "C:/development/projects/tensorflow/third_party/gpus/cuda_configure.bzl", line 846, in _create_cuda_repository
_get_cuda_config(repository_ctx)
File "C:/development/projects/tensorflow/third_party/gpus/cuda_configure.bzl", line 656, in _get_cuda_config
_cudnn_install_basedir(repository_ctx)
File "C:/development/projects/tensorflow/third_party/gpus/cuda_configure.bzl", line 211, in _cudnn_install_basedir
auto_configure_fail("Cannot find cudnn install path....)
File "C:/development/projects/tensorflow/third_party/gpus/cuda_configure.bzl", line 128, in auto_configure_fail
fail("
%sAuto-Configuration Error:%s ...))

Auto-Configuration Error: Cannot find cudnn install path.
and referenced by '//tensorflow/java:libtensorflow_jni.so'.
ERROR: Analysis of target '//tensorflow/java:libtensorflow_jni' failed; build aborted.
INFO: Elapsed time: 2.365s

Please go to Stack Overflow for help and support:

http://stackoverflow.com/questions/tagged/tensorflow

If you open a GitHub issue, here is our policy:

  1. It must be a bug or a feature request.
  2. The form below must be filled out.

Here's why we have that policy: TensorFlow developers respond to issues. We want to focus on work that benefits the whole community, e.g., fixing bugs and adding features. Support only helps individuals. GitHub also notifies thousands of people when issues are filed. We want them to see you communicating an interesting problem, rather than being redirected to Stack Overflow.


System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10, msys2 64bit
  • TensorFlow installed from (source or binary): Source
  • TensorFlow version (use command below): 1.1.0
  • Bazel version (if compiling from source): 0.4.5
  • CUDA/cuDNN version: 8.0/6.0
  • GPU model and memory: Quadro K5200
  • Exact command to reproduce: bazel build --config opt //tensorflow/java:tensorflow //tensorflow/java:libtensorflow_jni

You can collect some of this information using our environment capture script:

https://github.com/tensorflow/tensorflow/tree/master/tools/tf_env_collect.sh

You can obtain the TensorFlow version with

python -c "import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)"

Describe the problem

Describe the problem clearly here. Be sure to convey here why it's a bug in TensorFlow or a feature request.

Source code / logs

Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached. Try to provide a reproducible test case that is the bare minimum necessary to generate the problem.

Activity

  1. changed the title [-]Unable to build tensorflow for Java[/-] [+]Unable to build tensorflow for Java in Windows[/+] on May 17, 2017
  2. wendal commented on May 17, 2017

    @wendal

    I use cmake , it works!

  3. nectario commented on May 17, 2017

    @nectario
    Author

    I tried but cmake also failed for me... Can you give me instructions??

  4. nectario commented on May 17, 2017

    @nectario
    Author

    CMAKE gives me the following errors:

    The C compiler identification is MSVC 19.10.25019.0
    The CXX compiler identification is MSVC 19.10.25019.0
    Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/bin/Hostx86/x64/cl.exe
    Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/bin/Hostx86/x64/cl.exe -- works
    Detecting C compiler ABI info
    Detecting C compiler ABI info - done
    Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/bin/Hostx86/x64/cl.exe
    Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/bin/Hostx86/x64/cl.exe -- works
    Detecting CXX compiler ABI info
    Detecting CXX compiler ABI info - done
    Detecting CXX compile features
    Detecting CXX compile features - done
    Performing Test COMPILER_OPT_ARCH_NATIVE_SUPPORTED
    Performing Test COMPILER_OPT_ARCH_NATIVE_SUPPORTED - Failed
    Found PythonInterp: C:/ProgramData/Anaconda3/python.exe (found version "3.6")
    Found PythonLibs: C:/ProgramData/Anaconda3/libs/python36.lib (found version "3.6.0")
    CMake Error at C:/Program Files/CMake/share/cmake-3.8/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
    Could NOT find SWIG (missing: SWIG_EXECUTABLE SWIG_DIR)
    Call Stack (most recent call first):
    C:/Program Files/CMake/share/cmake-3.8/Modules/FindPackageHandleStandardArgs.cmake:377 (_FPHSA_FAILURE_MESSAGE)
    C:/Program Files/CMake/share/cmake-3.8/Modules/FindSWIG.cmake:63 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
    tf_python.cmake:656 (find_package)
    CMakeLists.txt:268 (include)

    Configuring incomplete, errors occurred!
    See also "C:/Temp/CMakeFiles/CMakeOutput.log".
    See also "C:/Temp/CMakeFiles/CMakeError.log".

  5. wendal commented on May 17, 2017

    @wendal
    Could NOT find SWIG (missing: SWIG_EXECUTABLE SWIG_DIR)
    

    you need swig

  6. nectario commented on May 17, 2017

    @nectario
    Author

    Thanks. Let me install that.

  7. nectario commented on May 17, 2017

    @nectario
    Author

    Now I get this:
    (even though I have installed CUDNN).

    CMake Error at CMakeLists.txt:221 (FILE):
    file COPY cannot find "/include/cudnn.h".

    Configuring incomplete, errors occurred!
    See also "C:/Temp/CMakeFiles/CMakeOutput.log".

  8. nectario commented on May 17, 2017

    @nectario
    Author

    Finally build it with CMAKE. So what do I do next to create the JNI libraries for Java?

  9. nectario commented on May 17, 2017

    @nectario
    Author

    When I build it on Visual Studio I get:

    187>Building Custom Rule C:/Development/Projects/tensorflow/tensorflow/contrib/cmake/CMakeLists.txt
    185>Building Custom Rule C:/Development/Projects/tensorflow/tensorflow/contrib/cmake/CMakeLists.txt
    186>Building Custom Rule C:/Development/Projects/tensorflow/tensorflow/contrib/cmake/CMakeLists.txt
    185>CMake does not need to re-run because C:/Development/Projects/tensorflow/cmake_build/CMakeFiles/generate.stamp is up-to-date.
    185>Building NVCC (Device) object CMakeFiles/cuda_compile_2.dir//rnn/kernels/Debug/cuda_compile_2_generated_lstm_ops_gpu.cu.cc.obj
    187>CMake does not need to re-run because C:/Development/Projects/tensorflow/cmake_build/CMakeFiles/generate.stamp is up-to-date.
    187>Building NVCC (Device) object CMakeFiles/cuda_compile_3.dir/
    /seq2seq/kernels/Debug/cuda_compile_3_generated_beam_search_ops_gpu.cu.cc.obj
    186>CMake does not need to re-run because C:/Development/Projects/tensorflow/cmake_build/CMakeFiles/generate.stamp is up-to-date.
    186>Building NVCC (Device) object CMakeFiles/cuda_compile_1.dir//rnn/kernels/Debug/cuda_compile_1_generated_gru_ops_gpu.cu.cc.obj
    185>Failed to run C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/bin (The system cannot find the file specified.
    185>
    185>).
    185>CMake Error at cuda_compile_2_generated_lstm_ops_gpu.cu.cc.obj.Debug.cmake:222 (message):
    185> Error generating
    185> C:/Development/Projects/tensorflow/cmake_build/CMakeFiles/cuda_compile_2.dir/
    /rnn/kernels/Debug/cuda_compile_2_generated_lstm_ops_gpu.cu.cc.obj
    185>
    185>
    186>Failed to run C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/bin (The system cannot find the file specified.
    186>
    186>).
    186>CMake Error at cuda_compile_1_generated_gru_ops_gpu.cu.cc.obj.Debug.cmake:222 (message):
    186> Error generating
    186> C:/Development/Projects/tensorflow/cmake_build/CMakeFiles/cuda_compile_1.dir//rnn/kernels/Debug/cuda_compile_1_generated_gru_ops_gpu.cu.cc.obj
    186>
    186>
    187>Failed to run C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/bin (The system cannot find the file specified.
    187>
    187>).
    187>CMake Error at cuda_compile_3_generated_beam_search_ops_gpu.cu.cc.obj.Debug.cmake:222 (message):
    187> Error generating
    187> C:/Development/Projects/tensorflow/cmake_build/CMakeFiles/cuda_compile_3.dir/
    /seq2seq/kernels/Debug/cuda_compile_3_generated_beam_search_ops_gpu.cu.cc.obj
    187>
    187>
    186>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(171,5): error MSB6006: "cmd.exe" exited with code 1.
    186>Done building project "_gru_ops.vcxproj" -- FAILED.
    187>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(171,5): error MSB6006: "cmd.exe" exited with code 1.
    187>Done building project "_beam_search_ops.vcxproj" -- FAILED.
    185>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(171,5): error MSB6006: "cmd.exe" exited with code 1.
    185>Done building project "_lstm_ops.vcxproj" -- FAILED.
    188>------ Build started: Project: tf_extension_ops, Configuration: Debug x64 ------
    189>------ Skipped Build: Project: ALL_BUILD, Configuration: Debug x64 ------
    189>Project not selected to build for this solution configuration
    188>Building Custom Rule C:/Development/Projects/tensorflow/tensorflow/contrib/cmake/CMakeLists.txt
    188>CMake does not need to re-run because C:/Development/Projects/tensorflow/cmake_build/CMakeFiles/generate.stamp is up-to-date.
    190>------ Skipped Build: Project: tf_python_build_pip_package, Configuration: Debug x64 ------
    190>Project not selected to build for this solution configuration
    ========== Build: 164 succeeded, 24 failed, 57 up-to-date, 2 skipped ==========

  10. nectario commented on May 17, 2017

    @nectario
    Author

    I really need to build tensorflow for Java with GPU support in Windows, and unfortunately, it is an extremely frustrating experience. :-( :-( Is there any place I can download the gpu JNI lib that has been pre-built?

  11. alive-zk commented on May 17, 2017

    @alive-zk

    This question is better asked on StackOverflow since it is not a bug or feature request. There is also a larger community that reads questions there. Thanks!

  12. nectario commented on May 18, 2017

    @nectario
    Author

    Thank you, will do.

  13. BensonBlack commented on May 25, 2017

    @BensonBlack

    Now I get this:
    (even though I have installed CUDNN).

    CMake Error at CMakeLists.txt:221 (FILE):
    file COPY cannot find "/include/cudnn.h".

    Configuring incomplete, errors occurred!
    See also "C:/Temp/CMakeFiles/CMakeOutput.log".

    @nectario
    How can you solve it?

  14. nectario commented on May 25, 2017

    @nectario
    Author

    I am having a similar issue building but without cmake. Very frustrating experience. Nobody from stackoverflow responded. The build script seems extremely buggy.

  15. wendal commented on May 25, 2017

    @wendal

    @nectario The CI is using cmake too.

  16. nectario commented on Jun 6, 2017

    @nectario
    Author

    This is a valid issue that should not be closed. Stackoverflow did not respond not even once. Please open it. When I run this command:
    bazel build --config opt //tensorflow/java:tensorflow //tensorflow/java:libtensorflow_jni
    I get:

    ERROR: C:/development/projects/tensorflow/tensorflow/java/BUILD:142:1: error loading package 'tensorflow/java/src/main/native': Encountered error while reading extension file cuda/build_defs.bzl: no such package '@local_config_cuda//cuda': Traceback (most recent call last):
            File "C:/development/projects/tensorflow/third_party/gpus/cuda_configure.bzl", line 958
                    _create_cuda_repository(repository_ctx)
            File "C:/development/projects/tensorflow/third_party/gpus/cuda_configure.bzl", line 846, in _create_cuda_repository
                    _get_cuda_config(repository_ctx)
            File "C:/development/projects/tensorflow/third_party/gpus/cuda_configure.bzl", line 656, in _get_cuda_config
                    _cudnn_install_basedir(repository_ctx)
            File "C:/development/projects/tensorflow/third_party/gpus/cuda_configure.bzl", line 211, in _cudnn_install_basedir
                    auto_configure_fail("Cannot find cudnn install path....)
            File "C:/development/projects/tensorflow/third_party/gpus/cuda_configure.bzl", line 128, in auto_configure_fail
                    fail("\n%sAuto-Configuration Error:%s...))
    
    **Auto-Configuration Error: Cannot find cudnn install path.**
     and referenced by //tensorflow/java:libtensorflow_jni.so.
    ERROR: Analysis of target //tensorflow/java:libtensorflow_jni failed; build aborted.
    INFO: Elapsed time: [0.672s]
    
  17. lostmsu commented on Aug 11, 2017

    @lostmsu

    @nectario how did you end up solving CudNN.h problem? Is there a hidden property I need to set?

  18. nectario commented on Aug 12, 2017

    @nectario
    Author

    I believe I had to set the property in cmake: CUDNN_HOME. I also set it as an environment variable. For example, my entry is:

    CUDNN_HOME = C:/Program Files/NVIDIA GPU Computing Toolkit/CUDNN/5.1/cuda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:support

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions