Skip to content
This repository was archived by the owner on May 28, 2024. It is now read-only.
This repository was archived by the owner on May 28, 2024. It is now read-only.

Windows missing unistd.h and getopt.h to build #101

@maxrohleder

Description

@maxrohleder

Setup:

  • running bazel 3.1.0 on powershell (msys2 in path for bash) (powershell is recommended here)
  • cuda 10.1 with cudNN 7.6 files copied into the respective folders (bin, lib, include)
  • Visual Studio 2019 Professional (Compiler Version 19.26.28806)

I confirmed here that these fit together.

Running configure.sh creates this .bazelrc for me:

build:cuda --define=using_cuda=true --define=using_cuda_nvcc=true
build:cuda --crosstool_top=@local_config_cuda//crosstool:toolchain
build --spawn_strategy=standalone
build --strategy=Genrule=standalone
build -c opt
build --copt=/experimental:preprocessor
build --host_copt=/experimental:preprocessor
build --action_env TF_HEADER_DIR="C:/Users/Max/Miniconda3/envs/tftest2/lib/site-packages/tensorflow/include"
build --action_env TF_SHARED_LIBRARY_DIR="C:/Users/Max/Miniconda3/envs/tftest2/lib/site-packages/tensorflow/python"
build --action_env TF_SHARED_LIBRARY_NAME="_pywrap_tensorflow_internal.lib"
build --action_env TF_NEED_CUDA="1"
build --action_env TF_CUDA_VERSION="10.1"
build --action_env TF_CUDNN_VERSION="7"
build --action_env CUDNN_INSTALL_PATH="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1"
build --action_env CUDA_TOOLKIT_PATH="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1"
build --config=cuda
test --config=cuda

As this looks fine, I run bazel build build_pip_pkg --verbose_failures, which failes with this error:

(tftest2) PS C:\Users\Max\Documents\win-pyronn> bazel build build_pip_pkg --verbose_failures                                                                                                                                                                              Extracting Bazel installation...
WARNING: Ignoring JAVA_HOME, because it must point to a JDK, not a JRE.
Starting local Bazel server and connecting to it...
INFO: Analyzed target //:build_pip_pkg (22 packages loaded, 100 targets configured).
INFO: Found 1 target...
ERROR: C:/users/Max/documents/win-pyronn/tensorflow_time_two/BUILD:32:1: C++ compilation of rule '//tensorflow_time_two:time_two_ops_gpu' failed (Exit 2): python.exe failed: error executing command
  cd C:/users/Max/_bazel_Max/tc4sfiy3/execroot/__main__
  SET CUDA_TOOLKIT_PATH=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1
    SET CUDNN_INSTALL_PATH=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1
    SET INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.26.28801\ATLMFC\include;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.26.28801\include;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared;C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt
    SET LIB=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.26.28801\ATLMFC\lib\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.26.28801\lib\x64;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64;
    SET PATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\\Extensions\Microsoft\IntelliCode\CLI;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.26.28801\bin\HostX64\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\VC\VCPackages;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\bin\Roslyn;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Team Tools\Performance Tools\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Team Tools\Performance Tools;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\\x64;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\CommonExtensions\Microsoft\FSharp\;C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64;C:\Program Files (x86)\Windows Kits\10\bin\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\\MSBuild\Current\Bin;C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\Tools\;;C:\WINDOWS\system32;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\VC\Linux\bin\ConnectionManagerExe
    SET PWD=/proc/self/cwd
    SET RUNFILES_MANIFEST_ONLY=1
    SET TEMP=C:\Users\Max\AppData\Local\Temp
    SET TF_CUDA_VERSION=10.1
    SET TF_CUDNN_VERSION=7
    SET TF_HEADER_DIR=C:/Users/Max/Miniconda3/envs/tftest2/lib/site-packages/tensorflow/include
    SET TF_NEED_CUDA=1
    SET TF_SHARED_LIBRARY_DIR=C:/Users/Max/Miniconda3/envs/tftest2/lib/site-packages/tensorflow/python
    SET TF_SHARED_LIBRARY_NAME=_pywrap_tensorflow_internal.lib
    SET TMP=C:\Users\Max\AppData\Local\Temp
  C:/Users/Max/Miniconda3/envs/tftest2/python.exe -B external/local_config_cuda/crosstool/windows/msvc_wrapper_for_nvcc.py /nologo /DCOMPILER_MSVC /DNOMINMAX /D_WIN32_WINNT=0x0600 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS /bigobj /Zm500 /J /Gy /GF /EHsc /wd4351 /wd4291 /wd4250 /wd4996 /I. /Ibazel-out/x64_windows-opt/bin /Iexternal/local_config_tf /Ibazel-out/x64_windows-opt/bin/external/local_config_tf /Iexternal/local_config_cuda /Ibazel-out/x64_windows-opt/bin/external/local_config_cuda /Ibazel-out/x64_windows-opt/bin/external/local_config_cuda/cuda/_virtual_includes/cuda_headers_virtual /Iexternal/local_config_tf/include /Ibazel-out/x64_windows-opt/bin/external/local_config_tf/include /Iexternal/local_config_cuda/cuda /Ibazel-out/x64_windows-opt/bin/external/local_config_cuda/cuda /Iexternal/local_config_cuda/cuda/cuda/include /Ibazel-out/x64_windows-opt/bin/external/local_config_cuda/cuda/cuda/include /showIncludes /MD /O2 /DNDEBUG /experimental:preprocessor /D__CLANG_SUPPORT_DYN_ANNOTATION__ /DEIGEN_MPL2_ONLY /DEIGEN_MAX_ALIGN_BYTES=64 /DEIGEN_HAS_TYPE_TRAITS=0 /DTF_USE_SNAPPY /showIncludes /MD /O2 /DNDEBUG /w -DWIN32_LEAN_AND_MEAN -DNOGDI /d2ReducedOptimizeHugeFunctions /arch:AVX /std:c++14 -DTENSORFLOW_MONOLITHIC_BUILD /DPLATFORM_WINDOWS /DEIGEN_HAS_C99_MATH /DTENSORFLOW_USE_EIGEN_THREADPOOL /DEIGEN_AVOID_STL_ARRAY /Iexternal/gemmlowp /wd4018 /wd4577 /DNOGDI /UTF_COMPILE_LIBRARY -DTENSORFLOW_USE_NVCC=1 -DGOOGLE_CUDA=1 -x cuda -nvcc_options=relaxed-constexpr -nvcc_options=ftz=true /Fobazel-out/x64_windows-opt/bin/tensorflow_time_two/_objs/time_two_ops_gpu/time_two_kernels.cu.o /c tensorflow_time_two/cc/kernels/time_two_kernels.cu.cc
Execution platform: @local_config_platform//:host
cl : Command line warning D9035 : option 'experimental:preprocessor' has been deprecated and will be removed in a future release
cl : Command line warning D9036 : use 'Zc:preprocessor' instead of 'experimental:preprocessor'
bazel-out/x64_windows-opt/bin/external/local_config_tf/include\unsupported/Eigen/CXX11/Tensor(74): fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory
Target //:build_pip_pkg failed to build
INFO: Elapsed time: 307.569s, Critical Path: 272.07s
INFO: 4 processes: 4 local.
FAILED: Build did NOT complete successfully

The build process fails while compiling the file from the time_two example /time_two_kernels.cu.o . From the error Cannot open include file: 'unistd.h , I recon that these are not included in the windows C++ standard libraries. A little bit of stackoverflow digging confirms this (see this thread). If I follow the advice from the thread and add a 'dummy' unistd.h in one of the include folders, a similar error occurs for getopt.h.

It is really frustrating for a windows user (not by choice) that even the example is so hard to build.

Before getting so far, I had to apply the #92 fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions