Errors when building TensorFlow with CMake on Windows 10 - tensorflow

I am attempting a TensorFlow CMake build on Windows, but I'm running into problems.
First, I run
C:\work\tensorflow\tensorflow\contrib\cmake\build>cmake .. -A x64 -DCMAKE_BUILD_TYPE=Release ^
More? -DSWIG_EXECUTABLE=C:/Program1/swigwin-3.0.12/swig.exe ^
More? -DPYTHON_EXECUTABLE=C:/Python3.5/python.exe ^
More? -DPYTHON_LIBRARIES=C:/Python3.5/libs/python35.lib ^
More? -Dtensorflow_ENABLE_GPU=ON ^
More? -DCUDNN_HOME="C:\Program1\cudnn\cuda"
and get the output
-- Building for: Visual Studio 14 2015
-- The C compiler identification is MSVC 19.0.24215.1
-- The CXX compiler identification is MSVC 19.0.24215.1
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/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 14.0/VC/bin/x86_amd64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/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 CUDA: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0 (found suitable version "8.0", minimum required is "8.0")
-- Found PythonInterp: C:/Python3.5/python.exe (found version "3.5")
-- Found PythonLibs: C:/Python3.5/libs/python35.lib (found version "3.5.0")
-- Found SWIG: C:/Program1/swigwin-3.0.12/swig.exe (found version "3.0.12")
-- Configuring done
-- Generating done
-- Build files have been written to: C:/work/tensorflow/tensorflow/contrib/cmake/build
The only troubling line here is -- Performing Test COMPILER_OPT_ARCH_NATIVE_SUPPORTED - Failed, which I don't really know what it means or whether it's a serious problem. (Is it?)
Second, I run
MSBuild /p:Configuration=Release tf_tutorials_example_trainer.vcxproj
and this gives me several errors:
"C:\work\tensorflow\tensorflow\contrib\cmake\build\tf_tutorials_example_trainer.vcxproj" (default target) (1) ->
"C:\work\tensorflow\tensorflow\contrib\cmake\build\tf_core_gpu_kernels.vcxproj" (default target) (90) ->
(CustomBuild target) ->
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(171,5): error MSB6006: "cmd.exe" exited with code 1. [C:\work\tensorflow\tensorflow\contrib\cmake\build\tf_core_gpu_kernels.vcxproj]
"C:\work\tensorflow\tensorflow\contrib\cmake\build\tf_tutorials_example_trainer.vcxproj" (default target) (1) ->
"C:\work\tensorflow\tensorflow\contrib\cmake\build\tf_core_kernels.vcxproj" (default target) (91) ->
(ClCompile target) ->
c:\work\tensorflow\tensorflow\core\kernels\cuda_solvers.h(24): fatal error C1083: Cannot open include file: 'cuda/include/cusolverDn.h': No such file or directory (compiling source file C:\work\tensorflow\tensorflow\core\kernels\cholesky_op.cc) [C:\work\tensorflow\tensorflow\contrib\cmake\build\tf_core_kernels.vcxproj]
c:\work\tensorflow\tensorflow\core\kernels\cuda_solvers.h(24): fatal error C1083: Cannot open include file: 'cuda/include/cusolverDn.h': No such file or directory (compiling source file C:\work\tensorflow\tensorflow\core\kernels\cuda_solvers.cc) [C:\work\tensorflow\tensorflow\contrib\cmake\build\tf_core_kernels.vcxproj]
c:\work\tensorflow\tensorflow\contrib\cmake\build\external\eigen_archive\eigen\src\core\coreevaluators.h(1052): fatal error C1060: compiler is out of heap space (compiling source file C:\work\tensorflow\tensorflow\core\kernels\svd_op_float.cc) [C:\work\tensorflow\tensorflow\contrib\cmake\build\tf_core_kernels.vcxproj]
696 Warning(s)
4 Error(s)
I don't know relative to which folder MSBuild is looking for cuda/include/cusolverDn.h. I don't have any folder called cuda in c:\work\tensorflow\tensorflow\core\kernels, and no file named cusolverDn.h exists anywhere in the tensorflow repository. (I do have the file cusolverDn.h in my CUDA install directory, though.) So,
What can I do to make MSBuild find cusolverDn.h? And what can I do to prevent the compiler from running out of heap space?
In a previous attempt to run the last command I also received the message
nvcc fatal : Microsoft Visual Studio configuration file 'vcvars64.bat' could not be found for installation at 'C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/../..'
Some recommend renaming a folder and a file in that folder. I can't really verify that this works right now since the problem temporarily seems to have disappeared (maybe masked by the "compiler is out of heap space" problem, which I didn't have before...).
Is renaming this file and this folder the correct solution?

As per tensorflow instructions check the following:
you must be running a 64 bit enabled Command Prompt for Visual Studio; you should run your msbuild.exe commands from such a prompt;
install CUDNN's Nvidia zio file and append its /bin/ directory to your PATH environment variable, it should contains two entries similar to the following:
D:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin
D:\YOURCUDNNPATH\cuda\bin
check whether both git and cmake command are available in the PATH; check whether you could run those commands from your prompt;

Related

Qt-Cretor + CMake insists on using MSVC when I want to use MinGW

I am trying to build a CMake project with MinGW. I have installed MinGW 8.1 through the Qt installer. The CMakeList is unchanged from how Qt Creator created it when creating the project.
When running CMake, I can see how Qt Creator passes the compiler and linker's paths to CMake and how CMake completely ignores them.
Führe C:\Program Files\CMake\bin\cmake.exe -S [snip] -B [snip] "-DCMAKE_BUILD_TYPE:String=Debug" "-DQT_QMAKE_EXECUTABLE:STRING=C:/Qt/5.15.1/mingw81_64/bin/qmake.exe" "-DCMAKE_PREFIX_PATH:STRING=C:/Qt/5.15.1/mingw81_64" "-DCMAKE_C_COMPILER:STRING=C:/Qt/Tools/mingw810_64/bin/gcc.exe" "-DCMAKE_CXX_COMPILER:STRING=C:/Qt/Tools/mingw810_64/bin/g++.exe" in [snip] aus.
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19041.
-- The CXX compiler identification is MSVC 19.24.28314.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
CMAKE_BUILD_TYPE
CMAKE_C_COMPILER
QT_QMAKE_EXECUTABLE
Here I am using a system install of CMake, but the output is unchanged when using the CMake installed with Qt Creator. The CMake generator for the selected kit is set to MinGW Makefiles in the Qt Creator settings. Running CMake manually, without Qt Creator, allows me to configure the project. (although it still doesn't compile because of a linker error, that I expect to be independent of this problem)
It seems there is a caching issue. The caching is done by CMake (CMakeCache.txt) and by QtCreator (CMakeLists.txt.user) itself.
Maybe this helps:
Close QtCreator (by closing QtCreator the CMakeLists.txt.user file is saved or generated if the file don't exist)
delete QtCreator's CMakeLists.txt.user
the build folder
Open the project again and select the desired kit.

Can't tell cmake to use vcpkg for library link

I'm using a Cmake for a cross-platform project that use glibmm. Under Linux, the project build successfully without any problem (and works fine when executed).
But with Windows 10, Visual Studio 2019 (pro), I can't find how to build the project. I installed glibmm with vcpkg ("vcpkg install glibmm:x64-windows" and "vcpkg install glibmm:x86-windows")
I add to my cmake command the parameter -DCMAKE_TOOLCHAIN_FILE=D:\vcpkg\scripts\buildsystems\vcpkg.cmake
In the main CMakeLists.txt file, the following lines do not do their job.
find_package(PkgConfig REQUIRED)
pkg_check_modules(glibmm REQUIRED glibmm-2.4)
cmake -S D:\MachDrivetoolkit\libMachDrive -DCMAKE_TOOLCHAIN_FILE=D:\vcpkg\scripts\buildsystems\vcpkg.cmake -DPKG_CONFIG_EXECUTABLE:STRING="D:\vcpkg\downloads\tools\msys2\c809757c94447846\mingw32\bin\pkg-config.exe" -B D:\MachDrivetoolkit\libMachDriveVS
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19041.
-- The CXX compiler identification is MSVC 19.28.29334.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: D:\vcpkg\downloads\tools\msys2\c809757c94447846\mingw32\bin\pkg-config.exe (found version "0.29.2")
-- Checking for module 'glibmm-2.4'
-- No package 'glibmm-2.4' found
CMake Error at C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.18/Modules/FindPkgConfig.cmake:545 (message):
A required package was not found
Call Stack (most recent call first):
C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.18/Modules/FindPkgConfig.cmake:733 (_pkg_check_modules_internal)
libipc/CMakeLists.txt:37 (pkg_check_modules)
Then I modify the name of the glibmm library in the script to match the name of the installed file
find_package(PkgConfig REQUIRED)
pkg_check_modules(glibmm REQUIRED glibmm)
but it fail the same.
What parameters or what instruction should I use to link glibmm to my project ?

Assimp compilation errors Win10 + Visual studio 2017 community

I can't get assimp compiled on my laptop (Windows 10, Visual studio 2017 community). Everything compiles nice on my work PC.
I just clone repo:
git clone https://github.com/assimp/assimp.git
cd assimp
mkdir build
cd build
cmake ..
here out of cmake command
-- Building for: Visual Studio 15 2017
-- The C compiler identification is MSVC 19.14.26428.1
-- The CXX compiler identification is MSVC 19.14.26428.1
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.14.26428/bin/Hostx86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.14.26428/bin/Hostx86/x86/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.14.26428/bin/Hostx86/x86/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.14.26428/bin/Hostx86/x86/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Shared libraries enabled
-- Looking for DirectX...
-- DirectX_PREFIX_PATH changed.
-- Could not locate DirectX
-- Looking for ZLIB...
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
-- Could not locate ZLIB
-- compiling zlib from souces
CMake Deprecation Warning at contrib/zlib/CMakeLists.txt:8 (cmake_policy):
The OLD behavior for policy CMP0048 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of off64_t
-- Check size of off64_t - failed
-- Looking for fseeko
-- Looking for fseeko - not found
-- Looking for unistd.h
-- Looking for unistd.h - not found
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
-- Could NOT find rt (missing: RT_LIBRARY)
-- Enabled formats: AMF 3DS AC ASE ASSBIN ASSXML B3D BVH COLLADA DXF CSM HMP IRRMESH IRR LWO LWS MD2 MD3 MD5 MDC MDL NFF NDO OFF OBJ OGRE OPENGEX PLY MS3D COB BLEND IFC XGL FBX Q3D Q3BSP RAW SIB SMD STL TERRAGEN 3D X X3D GLTF 3MF MMD
-- Disabled formats:
-- Could NOT find IL (missing: IL_LIBRARIES IL_INCLUDE_DIR)
CMake Warning at CMakeLists.txt:439 (MESSAGE):
Build of assimp_qt_viewer is disabled. Unsatisfied dendencies: Qt5 DevIL
-- Configuring done
-- Generating done
-- Build files have been written to:
this makes solution for my Visual studio, which I'm trying to build using Build All menu. I get following errors:
Severity Code Description Project File Line Suppression State
Error C2065 'AI_IMPORT_IFC_DEFAULT_SMOOTHING_ANGLE': undeclared identifier assimp
Error (active) E0020 identifier "AI_CONFIG_GLOBAL_SCALE_FACTOR_KEY" is undefined assimp
Error C2065 'AI_CONFIG_GLOBAL_SCALE_FACTOR_KEY': undeclared identifier assimp
But if I try to navigate to this define - Intellisense allow me to do this. I see this defines. What am I doing wrong, please help?

How to build a library using cmake in windows

I've tried to build a library (called libiec61850) using cmake in windows. I have installed cmake and configured the "path" environment with the directory where I have installed the cmake. Then,
1-I created a subfolder called "build" in my library's directory
2- I copy the subfolder directory in the command line and type
cmake -G "Visual Studio 14 2015" and got many errors as follows:
- la génération a démarré
- echec de la build
- Cmakeoutput.log : "The system is: Windows - 6.1.7601 - AMD64"
See the attached file.
Please, you help will be precious.error_cmake_windows
I just looked up the library and tried it out myself, and I got it to work.
I normally use NMake to compile Visual Studios programs. If you'd like to use the same, you need to make sure that the MSVC environment is set up properly before using it. I normally run vcvarsall.bat in cmd first like so:
D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat
You could do the same wherever your vcvarsall.bat file is in your Visual Studio 2015 folders (I used Visual Studio 2017, but it should work fine with Visual Studio 2015 as well).
Next, these were the commands that I used and their respective outputs:
D:\Users\patrick\src\vs2017>cd libiec61850
D:\Users\patrick\src\vs2017\libiec61850>mkdir build
D:\Users\patrick\src\vs2017\libiec61850>cd build
D:\Users\patrick\src\vs2017\libiec61850\build>cmake .. -G "NMake Makefiles"
-- The C compiler identification is MSVC 19.11.25547.0
-- The CXX compiler identification is MSVC 19.11.25547.0
-- Check for working C compiler: D:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503
/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: D:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503
/bin/Hostx64/x64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: D:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.255
03/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: D:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.255
03/bin/Hostx64/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for clock_gettime in rt
-- Looking for clock_gettime in rt - not found
-- Check if the system is big endian
-- Searching 16 bit integer
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of unsigned short
-- Check size of unsigned short - done
-- Using unsigned short
-- Check if the system is big endian - little endian
server-example-logging: sqlite not found
-- Generating RC file : D:/Users/patrick/src/vs2017/libiec61850/build/src/version.rc
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Failed
-- Performing Test COMPILER_HAS_DEPRECATED
-- Performing Test COMPILER_HAS_DEPRECATED - Success
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Users/patrick/src/vs2017/libiec61850/build
D:\Users\patrick\src\vs2017\libiec61850\build>nmake
Microsoft (R) Program Maintenance Utility Version 14.11.25547.0
Copyright (C) Microsoft Corporation. All rights reserved.
Scanning dependencies of target iec61850
[ 0%] Building CXX object src/CMakeFiles/iec61850.dir/common/string_map.c.obj
string_map.c
It then continued compiling.
Try all of that out. If you make a build directory, you probably need to 'cd' into it, and then run cmake with a '..' to indicate that the CMakeLists.txt directory is one directory up. Let me know if you can't use NMake or if it doesn't work.

Using CMake in mingw32 for a Fortran code

Here is a simple question, I need to create a CMake builder onto mingw32. I want to define the compiler in the CMakeLists.txt (although I want to specify that when calling cmake later). The txt file looks like this:
cmake_minimum_required(VERSION 3.4)
SET(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_GENERATOR "MinGW Makefiles")
message("generator is set to ${CMAKE_GENERATOR}")
#set (CMAKE_Fortran_COMPILER "C:/Program Files/PGI/win64/15.10/bin")
set (CMAKE_Fortran_COMPILER "C:/Program Files (x86)/Silverfrost/FTN95")
and it returns:
generator is set to MinGW Makefiles
-- The Fortran compiler identification is unknown
-- Check for working Fortran compiler: C:/Program Files (x86)/Silverfrost/FTN95
-- Check for working Fortran compiler: C:/Program Files (x86)/Silverfrost/FTN95 -- broken
CMake Error at C:/Program Files (x86)/CMake/share/cmake- 3.4/Modules/CMakeTestFortranCompiler.cmake:54 (message):
The Fortran compiler "C:/Program Files (x86)/Silverfrost/FTN95" is not able
to compile a simple test program.
What do I do wrong ? I understand it does not find the compiler correctly. Thank you for your help.
Edit. As suggested I post the CMakeError.log
Compiling the Fortran compiler identification source file "CMakeFortranCompilerId.F" failed.
Compiler: C:/Program Files (x86)/Silverfrost/FTN95
Build flags:
Id flags: -v
The output was:
Access is denied
Compiling the Fortran compiler identification source file "CMakeFortranCompilerId.F" failed.
Compiler: C:/Program Files (x86)/Silverfrost/FTN95
Build flags:
Id flags:
The output was:
Access is denied
Compiling the Fortran compiler identification source file "CMakeFortranCompilerId.F" failed.
Compiler: C:/Program Files (x86)/Silverfrost/FTN95
Build flags:
Id flags: -c
The output was:
Access is denied
Compiling the Fortran compiler identification source file "CMakeFortranCompilerId.F" failed.
Compiler: C:/Program Files (x86)/Silverfrost/FTN95
Build flags:
Id flags: -fpp
The output was:
Access is denied
Checking whether the Fortran compiler is Compaq using "-what" did not match "Compaq Visual Fortran":
Checking whether the Fortran compiler is NAG using "-V" did not match "NAG Fortran Compiler":
Determining if the Fortran compiler works failed with the following output:
Change Dir: C:/Users/RolandGuichard/Desktop/SATURN/SATGPU/testcm/CMakeFiles/CMakeTmp
Run Build Command:"C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/devenv.com" "CMAKE_TRY_COMPILE.sln" "/build" "Debug" "/project" "cmTC_e9efb"
The Application Data folder for Visual Studio could not be created.
Any more information I can track here ? Thank you.
To help others: After 4 years, i have hit the same issue. I solved it by making sure you point to the exact location of the FORTRAN executable in your CMakeList.txt like this : set(CMAKE_Fortran_COMPILER "C:/MinGW/bin/gfortran.exe"). This solves it for me. Let me know if it works.
As the Visual Studio generator does not support MinGW gfortran. They are totally separate ecosystems. Remove your build directory and create a fresh one.
so to define the generator what works for me is to define the it using a flag in the command line
cmake -G "MinGW Makefiles"
I have tried also to set the CMAKE_GENERATOR as a variable inside the CMakefile.txt
set(CMAKE_GENERATOR "MinGW Makefiles")
but for some reason, it did not work and I have to pass the generator in the command line