Tensorflow.dll (r1.6) @ Windows 10 (VS 2015)
官方文件不建议在visual studio的环境下自行编译tensorflow的涵式库。基于研究需求,需要在VC++的环境下使用tensorflow深度学习医学影像的特徵;并且能够及时互动并更新权重值。于是爬了很多分享文。没想到看似简单的编译却是如此的困难重重。
环境:
VS2015Anacoda3 5.2.0nVidia CUDA 9.0.176nVidia CUDNN 8.0cmake 3.12.2tensorflow r1.6Notepad++下载tensorflow r1.6后, 新增至资料夹 c:\tf\
CMake的Command Mode
以系统管理员身分开启命令提示字元
在cmake下新增build的资料夹
例如: c:\tf\tensorflow\contrib\cmake\build
cmake .. -G "Visual Studio 14 2015 Win64" -T host=x64 -DCMAKE_BUILD_TYPE=Release ^-Dtensorflow_VERBOSE=ON ^-Dtensorflow_ENABLE_GRPC_SUPPORT=OFF ^-Dtensorflow_BUILD_PYTHON_BINDINGS=OFF ^-Dtensorflow_BUILD_CC_EXAMPLE=OFF ^-Dtensorflow_BUILD_SHARED_LIB=ON ^-Dtensorflow_WIN_CPU_SIMD_OPTIONS=/arch:AVX2 ^-Dtensorflow_ENABLE_GPU=ON
在Notepad++开启 tensorflow\contrib\cmake\tools\create_def_file.py
在第48行用以下的宣告替代
EXCLUDE_RE = re.compile(r"RTTI|deleting destructor|::internal::|::`anonymous namespace'::|<lambda_[0-9a-z]+>|" r"std::_Vector_iterator<|std::_Vector_const_iterator<|std::_Vector_alloc<|" r"std::_Deque_iterator<|std::_Deque_alloc<|" r"std::_Tree_iterator<|std::_Tree_const_iterator<|std::_Tree_unchecked_const_iterator<|std::_Tree_comp_alloc<|std::_Tree_node<|" r"std::_List_iterator<|std::_List_const_iterator<|std::_List_unchecked_const_iterator<|std::_List_alloc<|" r"std::_Iterator012<|std::_Compressed_pair<")
编译
以系统管理员身分开启 VS2015 X64 Native Tools 命令提示字元
Release Mode
到安装的资料夹执行release编译
例如: c:\tf\tensorflow\contrib\cmake\build
MSBuild /p:Configuration=Release /verbosity:detailed all_build.vcxproj
时间约 3小时
完成后可以在c:\tf\tensorflow\contrib\cmake\build\release
找到tensorflow.dll, tensorflow.lib
Debug Mode
到安装的资料夹执行debug编译
例如: c:\tf\tensorflow\contrib\cmake\build
MSBuild /p:Configuration=Release /verbosity:detailed all_build.vcxproj
时间约 6小时
完成后可以在c:\tf\tensorflow\contrib\cmake\build\debug
找到tensorflow.dll, tensorflow.lib