Last active
January 8, 2018 18:32
-
-
Save Era-Dorta/a6a82b75ea8277d12829eee81d6d2203 to your computer and use it in GitHub Desktop.
Configuration for a Visual Studio project that depends on tensorflow.dll in C++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Follow instructions in the following link to compile tensorflow. | |
Build as a shared library -Dtensorflow_BUILD_SHARED_LIB=ON | |
https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/cmake | |
Create new empty project in visual studio. | |
A good example to test as main.cpp would be | |
https://github.com/tensorflow/tensorflow/blob/r1.2/tensorflow/examples/label_image/main.cc | |
The following assumes that Tensorflow was downloaded in C:\tensorflow-r1.2 | |
************ | |
Release | |
************ | |
Include directories | |
C:\tensorflow-r1.2;C:\tensorflow-r1.2\tensorflow\contrib\cmake\build;C:\tensorflow-r1.2\tensorflow\contrib\cmake\build\external\eigen_archive;C:\tensorflow-r1.2\third_party\eigen3;C:\tensorflow-r1.2\tensorflow\contrib\cmake\build\protobuf\src\protobuf\src%(AdditionalIncludeDirectories) | |
Preprocessor definitions | |
WIN32;_WINDOWS;NDEBUG;_ITERATOR_DEBUG_LEVEL=0;EIGEN_AVOID_STL_ARRAY;NOMINMAX;_WIN32_WINNT=0x0A00;LANG_CXX11;COMPILER_MSVC;OS_WIN;_MBCS;WIN64;WIN32_LEAN_AND_MEAN;NOGDI;PLATFORM_WINDOWS;TENSORFLOW_USE_EIGEN_THREADPOOL;EIGEN_HAS_C99_MATH;%(PreprocessorDefinitions) | |
Additional Library Directories | |
C:\tensorflow-r1.2\tensorflow\contrib\cmake\build\Release;C:\tensorflow-r1.2\tensorflow\contrib\cmake\build\protobuf\src\protobuf\Release;%(AdditionalLibraryDirectories) | |
Additional Dependencies | |
libprotobuf.lib;tensorflow.lib;%(AdditionalDependencies) | |
If the project compiles but it complains at run time about the tensorflow.dll, copy it to the project x64\Release folder. | |
************ | |
Debug | |
************ | |
Compile tensorflow static library in debug | |
MSBuild /p:Configuration=Debug tensorflow_static.vcxproj | |
Set the custom project to use the tensorflow_static.lib generated in the previous step | |
Include directories | |
C:\tensorflow-r1.2;C:\tensorflow-r1.2\tensorflow\contrib\cmake\build;C:\tensorflow-r1.2\tensorflow\contrib\cmake\build\external\eigen_archive;C:\tensorflow-r1.2\third_party\eigen3;C:\tensorflow-r1.2\tensorflow\contrib\cmake\build\protobuf\src\protobuf\src%(AdditionalIncludeDirectories) | |
Preprocessor definitions | |
WIN32;_WINDOWS;_ITERATOR_DEBUG_LEVEL=2;EIGEN_AVOID_STL_ARRAY;NOMINMAX;_WIN32_WINNT=0x0A00;LANG_CXX11;COMPILER_MSVC;OS_WIN;_MBCS;WIN64;WIN32_LEAN_AND_MEAN;NOGDI;PLATFORM_WINDOWS;TENSORFLOW_USE_EIGEN_THREADPOOL;EIGEN_HAS_C99_MATH; | |
Additional Library Directories | |
C:\tensorflow-r1.2\tensorflow\contrib\cmake\build\fft2d\src\fft2d\Debug;C:\tensorflow-r1.2\tensorflow\contrib\cmake\build\farmhash\src\farmhash\Debug;C:\tensorflow-r1.2\tensorflow\contrib\cmake\build\gif\src\gif-build\Debug;C:\tensorflow-r1.2\tensorflow\contrib\cmake\build\Debug;C:\tensorflow-r1.2\tensorflow\contrib\cmake\build\grpc\src\grpc\Debug;C:\tensorflow-r1.2\tensorflow\contrib\cmake\build\protobuf\src\protobuf\Debug; | |
Additional Dependencies | |
fft2d.lib;farmhash.lib;giflib.lib;gpr.lib;grpc_unsecure.lib;grpc++_unsecure.lib;tf_protos_cc.lib;libprotobufd.lib;/WHOLEARCHIVE:tensorflow_static.lib;%(AdditionalDependencies) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If we try to use "-Wl,--no-keep-memory" option in order to compile successfully Tensorflow with Cmake on 8GB of RAM and less system?