vs2015 cmake tensorflow-r1.12(GPU)编译生成lib与dll文件遇到的问题

正确编译,并已进行工程实验转到:https://blog.csdn.net/qq_35975447/article/details/91986142

一.Dtensorflow_ENABLE_GRPC_SUPPORT=OFF进行cmake

cmake .. -A x64 -DCMAKE_BUILD_TYPE=Release -DSWIG_EXECUTABLE=D:/Users/swigwin-4.0.0/swig.exe -DPYTHON_EXECUTABLE=D:/Users/Python/python3.exe -DPYTHON_LIBRARIES=D:/Users/Python/libs/python35.lib -Dtensorflow_ENABLE_GPU=ON -Dtensorflow_ENABLE_GRPC_SUPPORT=OFF -Dtensorflow_BUILD_SHARED_LIB=ON

1.Half.h文件

more than one instance of overloaded function "__hadd" matches the argument list:    tf_core_gpu_kernels    d:\users\tensorflow-r1.12\tensorflow\contrib\cmake\build\external\eigen_archive\eigen\src\Core\arch\CUDA\Half.h    212    

双击出错的问题,编辑Half.h文件

EIGEN_STRONG_INLINE __device__ half operator + (const half& a, const half& b) {
  return __hadd(a, b);
}

为:

 EIGEN_STRONG_INLINE __device__ half operator + (const half& a, const half& b) {
 #if defined(EIGEN_CUDACC_VER) && EIGEN_CUDACC_VER >= 90000
   return __hadd(::__half(a), ::__half(b));
 #else
   return __hadd(a, b);
 #endif
 }
EIGEN_STRONG_INLINE __device__ half operator / (const half& a, const half& b) {
  float num = __half2float(a);
  float denom = __half2float(b);
  return __float2half(num / denom);
}

 为:

 EIGEN_STRONG_INLINE __device__ half operator / (const half& a, const half& b) {
 #if defined(EIGEN_CUDACC_VER) && EIGEN_CUDACC_VER >= 90000
   return __hdiv(a, b);
 #else
   float num = __half2float(a);
   float denom = __half2float(b);
   return __float2half(num / denom);
 #endif
 }

此处参考:https://blog.csdn.net/heiheiya/article/details/88946426 

2.“grpc/grpc.h”: No such file or directory

无法打开包括文件: “grpc/grpc.h”: No such file or directory (编译源文件 D:\Users\tensorflow-r1.12\tensorflow\c\eager\c_api_debug.cc)	tf_c	d:\users\tensorflow-r1.12\tensorflow\core\distributed_runtime\rpc\grpcpp\grpcpp.h	50	

github下载解压grpc,将include路径加入到对应错误项目(tf_c,pywrap_tensorflow_internal,pywrap_tensorflow_internal_static)的包含目录下:

 

 3.“unicode/errorcode.h”: No such file or directory

无法打开包括文件: “unicode/errorcode.h”: No such file or directory	tf_core_kernels	D:\Users\tensorflow-r1.12\tensorflow\core\kernels\unicode_script_op.cc	16	

下载icu-master,然后将icu4c/include目录添加到出错的项目(tf_core_kernels),其包含目录中

扫描二维码关注公众号,回复: 10448435 查看本文章

4.解决icu_64 无法解析的外部符号

在使用cmake+vs2015编译tensorflow1.12过程中,由于tensorflow github上仅有2个issue提到这个问题,但是还没给到解决办法,所以这里记录以下。

github上出现的issue:

https://github.com/tensorflow/tensorflow/issues/23963

https://github.com/tensorflow/tensorflow/issues/24499

无法解析的外部符号"__declspec(dllimport) public: virtual __cdecl icu_64::ErrorCode::~ErrorCode(void)" (__imp_??1ErrorCode@icu_64@@UEAA@XZ),该符号在函数 "public: virtual void __cdecl tensorflow::UnicodeScriptOp::Compute(class tensorflow::OpKernelContext *)" (?Compute@UnicodeScriptOp@tensorflow@@UEAAXPEAVOpKernelContext@2@@Z)    中被引用	transform_graph	D:\Users\tensorflow- r1.12\tensorflow\contrib\cmake\build\unicode_script_op.obj	1	

通过编译icu4c,将生成的lib64中的lib全部添加到出错项目(transform_graph,tf_tutorials_example_trainer,tf_label_image_example,tensorflow,summarize_graph,compare_graphs,benchmark_model)的附加依赖库,并添加附加库目录,就可以解决该问题。

打开allinonce目录下的allinonce.sln文件,设置为Release x64生成解决方案

通过生成解决方案,生成lib64文件夹,将该文件夹,添加到lib文件与该lib文件路径分别到附加依赖性与附加库目录:

                                icudt.lib
                                icuin.lib
                                icuio.lib
                                icutest.lib
                                icutu.lib
                                icuuc.lib

 (其中可以进入对应目录下,使用命令tree /f 方便得到lib文件,而不用一个个复制)

 5.absl无法解析的外部符号

无法解析的外部符号"class absl::uint128 __cdecl absl::operator/(class absl::uint128,class absl::uint128)"(??Kabsl@@YA?AVuint128@0@V10@0@Z),该符号在函数 "private: void __cdecl absl::str_format_internal::`anonymousnamespace'::ConvertedIntInfo::UnsignedToStringRight<class absl::uint128>(class absl::uint128,struct absl::str_format_internal::ConversionChar)(??$UnsignedToStringRight@Vuint128@absl@@@ConvertedIntInfo@?A0xfba7cd46@str_format_internal@absl@@AEAAXVuint128@3@UConversionChar@23@@Z) 中被引用	transform_graph	D:\Users\tensorflow-r1.12\tensorflow\contrib\cmake\build\str_format_internal.lib(arg.obj)

将编译过程中生成的Release目录下以下lib文件添加到出错项目(transform_graph,tf_tutorials_example_trainer,tf_label_image_example,tensorflow,summarize_graph,compare_graphs,benchmark_model,)附加依赖性中,并为其添加附加库目录:

  6.tensorflow::NewRemoteDevices等无法解析的外部符号

问题如(https://blog.csdn.net/wfafa/article/details/84072495 2楼评论)

class tensorflow::eager::EagerClientCache, tensorflow::NewRemoteDevices,tensorflow::Status

二.Dtensorflow_ENABLE_GRPC_SUPPORT=ON进行cmake

cmake .. -A x64 -DCMAKE_BUILD_TYPE=Release -DSWIG_EXECUTABLE=D:/Users/swigwin-4.0.0/swig.exe -DPYTHON_EXECUTABLE=D:/Users/Python/python3.exe -DPYTHON_LIBRARIES=D:/Users/Python/libs/python35.lib -Dtensorflow_ENABLE_GPU=ON -Dtensorflow_ENABLE_GRPC_SUPPORT=ON -Dtensorflow_BUILD_SHARED_LIB=ON

遇到以下问题(如https://blog.csdn.net/jiugeshao/article/details/79144438#commentsedit6楼评论),没找到解决方案,其中grpc及其第三方子文件下载不全!!!

1、无法打开包括文件: “tensorflow/core/framework/tensor.pb_text.h”: No such file or directory 

2、无法打开包括文件: “tensorflow/core/framework/device_attributes.pb_text.h”: No such file or directory 

3、LNK1181 无法打开输入文件“grpc\src\grpc\Release\grpc++_unsecure.lib”
发布了24 篇原创文章 · 获赞 11 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/qq_35975447/article/details/91348525