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

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

Closed
maxrohleder opened this issue Apr 22, 2021 · 2 comments
Closed

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

maxrohleder opened this issue Apr 22, 2021 · 2 comments

Comments

@maxrohleder
Copy link
Owner

Build 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.

Preparations:

This repository includes the tensorflow/custom-op code with the two example ops replaced with the pyronn-layers following the steps described here. Additionally the fixes to the problems described in #1 and #2 were fixed. These changes are minimal and should not affect the build.

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/z0045kxy/Miniconda3/envs/tftest2/lib/site-packages/tensorflow/include"
build --action_env TF_SHARED_LIBRARY_DIR="C:/Users/z0045kxy/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

The error:

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

(tftest2) PS C:\Users\z0045kxy\Documents\win-pyronn> bazel build build_pip_pkg --verbose_failures
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 (21 packages loaded, 105 targets configured).
INFO: Found 1 target...
INFO: Deleting stale sandbox base C:/users/z0045kxy/_bazel_z0045kxy/tc4sfiy3/sandbox
ERROR: C:/users/z0045kxy/documents/win-pyronn/pyronn_layers/BUILD:32:1: C++ compilation of rule '//pyronn_layers:pyronn_layers_ops_gpu' failed (Exit 2): python.exe failed: error executing command
  cd C:/users/z0045kxy/_bazel_z0045kxy/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\z0045kxy\AppData\Local\Temp
    SET TF_CUDA_VERSION=10.1
    SET TF_CUDNN_VERSION=7
    SET TF_HEADER_DIR=C:/Users/z0045kxy/Miniconda3/envs/tftest2/lib/site-packages/tensorflow/include
    SET TF_NEED_CUDA=1
    SET TF_SHARED_LIBRARY_DIR=C:/Users/z0045kxy/Miniconda3/envs/tftest2/lib/site-packages/tensorflow/python
    SET TF_SHARED_LIBRARY_NAME=_pywrap_tensorflow_internal.lib
    SET TMP=C:\Users\z0045kxy\AppData\Local\Temp
  C:/Users/z0045kxy/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/pyronn_layers/_objs/pyronn_layers_ops_gpu/cone_projector_3D_CudaKernel_hardware_interp.cu.o /c pyronn_layers/cc/kernels/cone_projector_3D_CudaKernel_hardware_interp.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: 33.424s, Critical Path: 26.77s
INFO: 0 processes.
FAILED: Build did NOT complete successfully

Possible origin:

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.

@maxrohleder
Copy link
Owner Author

maxrohleder commented Apr 22, 2021

I tryied adding the two header files from here and here to the root folder of the project, as . is listed as an include directory:

/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

I had to remove all typedefs and the defines for rand.

When this is done, the compilation is successful, but bazel throws this error:

ERROR: C:/users/z0045kxy/documents/win-pyronn/pyronn_layers/BUILD:32:1: undeclared inclusion(s) in rule '//pyronn_layers:pyronn_layers_ops_gpu':
this rule is missing dependency declarations for the following files included by 'pyronn_layers/cc/kernels/cone_backprojector_3D_CudaKernel.cu.cc':
  'unistd.h'
  'getopt.h'

Anyone knows how to adapt the BUILD file to allow this? Or is the approach generally set up to fail?

@maxrohleder
Copy link
Owner Author

FIX:

Editing this file: bazel-out/x64_windows-opt/bin/external/local_config_tf/include\unsupported/Eigen/CXX11/Tensor(74) is no use, as it gets created again on every build.

Instead, modify the source of the tensorflow library you are building against. For me, this is at:
C:\Users\z0045kxy\Miniconda3\envs\tftest2\Lib\site-packages\tensorflow\include\unsupported\Eigen\CXX11\Tensor

Open this file and remove #include <unistd.h> from line l. 74

After that, run

bazel clean --expunge
bazel build --enable_runfiles build_pip_pkg --verbose_failures

to start a clean rebuild.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant