windows+bazel+tensorflow-v1.12.0(GPU)編譯生成dll與lib

 目錄

0.最終環境

1.安裝 vs2015、cuda9.0、python3.5+

2.安裝 MSYS2

3.安裝 Bazel

4.下載tensorflow-v1.12

5.修改文件配置

6.使用powershell進行配置與編譯

7.vs無法解析的外部符號與powershell編譯出現無法解析的外部符號錯誤

8.準備tensorflow的dll、lib、include

8.1 簡版tensorflow的dll、lib、include

9.調用模型測試程序

10.嘗試編譯debug版本

11.遇到的問題

12.參考


這篇博客寫着,是因爲windows+bazel+tensorflow-r1.12(GPU)編譯生成dll與lib,上一篇,雖然編譯成功了,但是在使用tensorflow\examples\label_image\main.cc怎麼都不能成功生成解決方案,因爲缺很多鏈接庫。所以寫了這篇。

其中,我已經編譯好的tensorflow-v1.12.0 dll,lib,include,如何出現缺鏈接庫的話,自己可以將錯誤的符號加入tf_exported_symbols_msvc.lds文件中,自己編譯生成自己的dll與lib文件:

下載鏈接:

tensorflow-v1.12.0 dll,lib,include

提取碼:

0ugf

0.最終環境

  1. win10
  2. vs2015
  3. cuda9.0
  4. cudnn7.6
  5. python3.5.2
  6. tensorflow-v1.12.0
  7. bazel0.22.0
  8. msys2-x86_64-20190524

1.安裝 vs2015、cuda9.0、python3.5+

2.安裝 MSYS2

http://www.msys2.org/下載,

其中這個最好按照默認路徑安裝,否則編譯時沒過幾秒鐘,可能會出現下面的問題:

/usr/bin/env: 'python': No such file or directory windows

 所有安裝步驟都默認一路next下去,安裝完成以後,需要配置:

  • 將目錄C:\msys64和C:\msys64\usr\bin 加入系統環境變量path
  • 打開cmd.exe,輸入一下命令(有時可能安裝不了,多試幾次好了):
pacman -Syuu patch

3.安裝 Bazel

在github下載Bazel,https://github.com/bazelbuild/bazel/releases,這裏我下載的bazel-0.22.0-windows-x86_64.exe

將下載好的 bazel-0.22.1-windows-x86_64.exe複製到C:\msys64下,更名爲bazel.exe。

配置bazel:新建環境變量:BAZEL_SH,BAZEL_VC ,BAZEL_VS

 

4.下載tensorflow-v1.12

git與直接下載都可以,我是直接下載的壓縮包。

5.修改文件配置

此處參考https://github.com/guikarist/tensorflow-windows-build-script

1.將tensorflow-1.12.0.zip解壓到tensorflow-1.12.0目錄下,並將目錄下的tensorflow-1.12.0文件夾重命名爲source;

2.下載tensorflow-windows-build-script的壓縮包,解壓,將其中的patchs與build.ps.1複製到tensorflow-1.12.0目錄下;

3.將patchs下的eigen_half.patch複製到tensorflow-1.12.0\source\third_party下;

 4.將patchs下的tf_exported_symbols_msvc.lds複製到tensorflow-1.12.0\source\tensorflow下,這裏使用我編譯使用過的tf_exported_symbols_msvc.lds替換;

 5.可以使用Notepad++修改build.ps1文件如下(後面可能會出現Copy-Item命令的問題);

修改 line154-182:

  1. # Apply patches to source.
  2. if ($buildVersion -eq "v1.11.0") {
  3. # Eigen Patch for v1.11.0
  4. git apply --ignore-space-change --ignore-white "..\patches\eigen.1.11.0.patch"
  5. Copy-Item ..\patches\eigen_half.patch third_party\
  6. } elseif ($buildVersion -eq "v1.12.0") {
  7. # Eigen Patch for v1.12.0
  8. git apply --ignore-space-change --ignore-white "..\patches\eigen.1.12.0.patch"
  9. Copy-Item ..\patches\eigen_half.patch third_party\
  10. } elseif ($buildVersion -eq "v1.13.1") {
  11. [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
  12. (Invoke-WebRequest https://github.com/tensorflow/tensorflow/commit/ec727016282383aacf9d26386b01f6bdbd65b14b.patch).Content | git apply -v --ignore-space-change --ignore-white
  13. }
  14. if ($BuildCppAPI) {
  15. if ($buildVersion -eq "v1.11.0") {
  16. # C++ Symbol Patch for v1.11.0
  17. git apply --ignore-space-change --ignore-white "..\patches\cpp_symbol.1.11.0.patch"
  18. Copy-Item ..\patches\tf_exported_symbols_msvc.lds tensorflow\
  19. } elseif ($buildVersion -eq "v1.12.0") {
  20. # C++ Symbol Patch for v1.12.0
  21. git apply --ignore-space-change --ignore-white "..\patches\cpp_symbol.1.12.0.patch"
  22. Copy-Item ..\patches\tf_exported_symbols_msvc.lds tensorflow\
  23. } elseif ($buildVersion -eq "v1.13.1") {
  24. # C++ Symbol Patch for v1.13.1
  25. git apply --ignore-space-change --ignore-white "..\patches\cpp_symbol.1.13.1.patch"
  26. Copy-Item ..\patches\tf_exported_symbols_msvc.lds tensorflow\
  27. }
  28. }

爲:

  1. 爲:
  2. # Apply patches to source.
  3. if ($buildVersion -eq "v1.11.0") {
  4. # Eigen Patch for v1.11.0
  5. git apply --ignore-space-change --ignore-white "..\patches\eigen.1.11.0.patch"
  6. Copy-Item ..\patches\eigen_half.patch third_party\
  7. } elseif ($buildVersion -eq "v1.12.0") {
  8. # Eigen Patch for v1.12.0
  9. git apply --ignore-space-change --ignore-white "..\patches\eigen.1.12.0.patch"
  10. #Copy-Item ..\patches\eigen_half.patch third_party\
  11. } elseif ($buildVersion -eq "v1.13.1") {
  12. [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
  13. (Invoke-WebRequest https://github.com/tensorflow/tensorflow/commit/ec727016282383aacf9d26386b01f6bdbd65b14b.patch).Content | git apply -v --ignore-space-change --ignore-white
  14. }
  15. if ($BuildCppAPI) {
  16. if ($buildVersion -eq "v1.11.0") {
  17. # C++ Symbol Patch for v1.11.0
  18. git apply --ignore-space-change --ignore-white "..\patches\cpp_symbol.1.11.0.patch"
  19. Copy-Item ..\patches\tf_exported_symbols_msvc.lds tensorflow\
  20. } elseif ($buildVersion -eq "v1.12.0") {
  21. # C++ Symbol Patch for v1.12.0
  22. git apply --ignore-space-change --ignore-white "..\patches\cpp_symbol.1.12.0.patch"
  23. #Copy-Item ..\patches\tf_exported_symbols_msvc.lds tensorflow\
  24. } elseif ($buildVersion -eq "v1.13.1") {
  25. # C++ Symbol Patch for v1.13.1
  26. git apply --ignore-space-change --ignore-white "..\patches\cpp_symbol.1.13.1.patch"
  27. Copy-Item ..\patches\tf_exported_symbols_msvc.lds tensorflow\
  28. }
  29. }

6.使用powershell進行配置與編譯

1.打開powershell

輸入下面命令,這是bazel編譯的選項,爲不同的語言(python、c、c++)其//後對應的都不一樣:

$parameterString = "--config=opt --config=cuda --define=no_tensorflow_py_deps=true --copt=-nvcc_options=disable-warnings //tensorflow:libtensorflow_cc.so --verbose_failures"

bazel編譯的選項,爲不同的語言(python、c、c++)其//後對應的都不一樣,參考https://github.com/guikarist/tensorflow-windows-build-script

然後輸入:

  1. .\build.ps1 `
  2. -BazelBuildParameters $parameterString `
  3. -BuildCppAPI -ReserveSource

會出現build.ps1錯誤:無法加載文件 ******.ps1,因爲在此係統中禁止執行腳本,參考https://www.cnblogs.com/zhaozhan/archive/2012/06/01/2529384.html,解決輸入一下命令:

set-executionpolicy remotesigned

下面執行開始需要互動配置瞭如下(如果出錯重新編譯的話,最好刪除編譯目錄下,建的venv文件夾):

  1. (venv) PS D:\Users\tensorflow-1.12.0> .\build.ps1 `
  2. >> -BazelBuildParameters $parameterString `
  3. >> -BuildCppAPI -ReserveSource
  4. Select a Tensorflow version:
  5. [1] 1 - v1.13.1 [2] 2 - v1.12.0 [3] 3 - v1.11.0 [S] Select another version [?] 幫助 (默認值爲“1”): 2
  6. ...
  7. Starting local Bazel server and connecting to it...
  8. .
  9. INFO: Starting clean.
  10. WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown".
  11. You have bazel 0.15.0 installed.
  12. Do you wish to build TensorFlow with Apache Ignite support? [Y/n]: n
  13. No Apache Ignite support will be enabled for TensorFlow.
  14. Do you wish to build TensorFlow with XLA JIT support? [y/N]: n
  15. No XLA JIT support will be enabled for TensorFlow.
  16. Do you wish to build TensorFlow with ROCm support? [y/N]: n
  17. No ROCm support will be enabled for TensorFlow.
  18. Do you wish to build TensorFlow with CUDA support? [y/N]: y
  19. CUDA support will be enabled for TensorFlow.
  20. Please specify the CUDA SDK version you want to use. [Leave empty to default to CUDA 9.0]:
  21. Please specify the location where CUDA 9.0 toolkit is installed. Refer to README.md for more details. [Default is C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.0]: D:\Users\CUDA9.0
  22. Please specify the cuDNN version you want to use. [Leave empty to default to cuDNN 7]:
  23. Please specify the location where cuDNN 7 library is installed. Refer to README.md for more details. [Default is D:/Users/CUDA9.0]:
  24. Please specify a list of comma-separated Cuda compute capabilities you want to build with.
  25. You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus.
  26. Please note that each additional compute capability significantly increases your build time and binary size. [Default is: 3.5,7.0]: 5.0
  27. Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is /arch:AVX]:
  28. Would you like to override eigen strong inline for some C++ compilation to reduce the compilation time? [Y/n]: y
  29. Eigen strong inline overridden.
  30. Starting local Bazel server and connecting to it...
  31. .....................
  32. WARNING: The following configs were expanded more than once: [cuda]. For repeatable flags, repeats are counted twice and may lead to unexpected behavior.

編譯好以後,將

 

7.vs無法解析的外部符號與powershell編譯出現無法解析的外部符號錯誤

出現下面問題都按這個步驟做,只不過第4步中,vs是加上,powershell可能會加上或者去掉tf_exported_symbols_msvc.lds文件EXPORTS中的鏈接:

1.如果是vs無法解析的外部符號,這樣解決,錯誤與解決方案如下(爲了能清):

  • 錯誤:
無法解析的外部符號 "public: virtual __cdecl tensorflow::internal::LogMessage::~LogMessage(void)" (??1LogMessage@internal@tensorflow@@UEAA@XZ),該符號在函數 "public: void __cdecl tensorflow::internal::LogMessage::`vbase destructor'(void)" (??_DLogMessage@internal@tensorflow@@QEAAXXZ) 中被引用huawei_video_tensorflow
  • 解決方法:函數調用後與(該符號該符號在函數)前括號內的內容添加
??1LogMessage@internal@tensorflow@@UEAA@XZ

複製到tensorflow-1.12.0\source\tensorflow\tf_exported_symbols_msvc.lds文件的EXPORTS最後面。

2.如果powershell編譯出現無法解析的外部符號錯誤

  • 錯誤:
無法解析的外部符號 "public: virtual __cdecl tensorflow::internal::LogMessage::~LogMessage(void)" (??1LogMessage@internal@tensorflow@@UEAA@XZ),該符號在函數 "public: void __cdecl tensorflow::internal::LogMessage::`vbase destructor'(void)" (??_DLogMessage@internal@tensorflow@@QEAAXXZ) 中被引用
  • 解決方法:(該符號該符號在函數)前括號內的內容,從tensorflow-1.12.0\source\tensorflow\tf_exported_symbols_msvc.lds文件中所有包含的部分全部刪除:
??1LogMessage@internal@tensorflow@@UEAA@XZ

最後不斷解決重複解決遇到的頭文件與無法解析外部符號問題,終於編譯工程並能夠正常運行程序了。

通過這個步驟,在另外一臺機器上也測試成功了:

 

8.準備tensorflow的dll、lib、include

新建tensorflow文件夾,然後在目錄下再新建兩個目錄,dll與lib

dll:將上面圖片中路徑的libtensorflow_cc.so改名爲tensorflow_cc.dll,放到tensorflow\dll目錄下(vs調試時會調用的文件,路徑要加入到環境變量中,或者也可以將文件加到當前工程運行的release目錄下)

lib:將上面圖片路徑下的liblibtensorflow_cc.so.ifso改名爲tensorflow_cc.lib,放到tensorflow\lib目錄下 (路徑要加入到vs包含庫目錄中,或將文件放到當前工程運行的release目錄下,並添加庫目錄)

include:將bazel_source目錄下,不管是快捷方式(可能會複製不全,可以去上圖中目錄下,找到對應文件,反正一定要複製全,不要有空目錄,不然就會缺失頭文件,報錯),還是文件內的文件,都需要一起復制到tensorflow下。

下面是我自己編譯好的tensorflow-v1.12.0 dll,lib,include,如何出現缺鏈接庫的話,自己可以將錯誤的符號加入tf_exported_symbols_msvc.lds文件中,自己編譯生成自己的dll與lib文件:

提取碼:

0ugf

可以使用Dependency Walker工具查看該DLL:

8.1 簡版tensorflow的dll、lib、include

此處感謝cjAlgthm!!!

1.首先給出文件結構圖:

  1. libtensorflow
  2. ├─bin
  3. │ tensorflow_cc.dll
  4. ├─include
  5. │ ...
  6. └─lib
  7. tensorflow_cc.lib

 2.下載鏈接:

鏈接:libtensorflow
提取碼:rgzf 
 

3.使用

--解壓後,將libtensorflow/include加入包含目錄;

--將lib路徑包含到庫目錄,也可以放到對應工程的生成目錄中,比如x64/Release/,同樣也需要包含到庫目錄下;(這裏我是放到對應工程的生成目錄下,使用的相對路徑)

 且需要放到附加依賴項中:

--將dll放到對應工程的生成目錄中,比如x64/Release/,或者將路徑添加到系統環境變量中也可以。

4.如何整理此環境,可以參考

https://blog.csdn.net/carbon06/article/details/82588150

5.對於想更改tensorflow_cc名的

請注意:

  1. 不要改,很麻煩,lib裏面已經將dll名稱寫固定了;
  2. 想嘗試的,備份!!!lib修改後,有可能損壞。

6.demo測試結果

7.對tensorflow的庫做了如下修改

修改了下面三個文件:

將這幾個文件中的min與max修改成下面這樣:

  1. string_view.h
  2. line491-493
  3. private:
  4. static constexpr size_type kMaxSize =
  5. std::numeric_limits<difference_type>::max();
  6. 改爲
  7. private:
  8. static constexpr size_type kMaxSize =
  9. (std::numeric_limits<difference_type>::max)();

 

 

9.調用模型測試程序

這部分主要參考,以及博主的cv版本代碼

下面是我自己的批處理測試單張圖像代碼:

  1. #define COMPILER_MSVC
  2. #define NOMINMAX
  3. #define PLATFORM_WINDOWS // 指定使用tensorflow/core/platform/windows/cpu_info.h
  4. #include<iostream>
  5. #include<opencv2/opencv.hpp>
  6. #include"tensorflow/core/public/session.h"
  7. #include "tensorflow/core/platform/env.h"
  8. #include <time.h>
  9. using namespace tensorflow;
  10. using namespace cv;
  11. using std::cout;
  12. using std::endl;
  13. int main() {
  14. const std::string model_path = "E:/c++work/tf_testdemo/tf_testdemo/latest_model_MobileUNet_0603.pb";// tensorflow模型文件,注意不能含有中文
  15. const std::string image_path = "E:/c++work/tf_testdemo/tf_testdemo/001_00045.png"; // 待inference的圖片grace_hopper.jpg
  16. // 設置輸入圖像
  17. cv::Mat img = cv::imread(image_path);
  18. cv::cvtColor(img, img, cv::COLOR_BGR2RGB);
  19. //resize(img, img, cv::Size(512, 512),0,0, INTER_NEAREST);
  20. int height = img.rows;
  21. int width = img.cols;
  22. int depth = img.channels();
  23. // 圖像預處理
  24. img = (img - 0) / 255.0;
  25. img.convertTo(img, CV_32F);
  26. // 取圖像數據,賦給tensorflow支持的Tensor變量中
  27. const float* source_data = (float*)img.data;
  28. tensorflow::Tensor input_tensor(DT_FLOAT, TensorShape({ 1, height, width, depth })); //這裏只輸入一張圖片,參考tensorflow的數據格式NHWC
  29. auto input_tensor_mapped = input_tensor.tensor<float, 4>(); // input_tensor_mapped相當於input_tensor的數據接口,“4”表示數據是4維的。後面取出最終結果時也能看到這種用法
  30. // 把數據複製到input_tensor_mapped中,實際上就是遍歷opencv的Mat數據
  31. for (int i = 0; i < height; i++) {
  32. const float* source_row = source_data + (i * width * depth);
  33. for (int j = 0; j < width; j++) {
  34. const float* source_pixel = source_row + (j * depth);
  35. for (int c = 0; c < depth; c++) {
  36. const float* source_value = source_pixel + c;
  37. input_tensor_mapped(0, i, j, c) = *source_value;
  38. //printf("%d");
  39. }
  40. }
  41. }
  42. // 初始化tensorflow session
  43. Session* session;
  44. Status status = NewSession(SessionOptions(), &session);
  45. if (!status.ok()) {
  46. std::cerr << status.ToString() << endl;
  47. return -1;
  48. }
  49. else {
  50. cout << "Session created successfully" << endl;
  51. }
  52. // 讀取二進制的模型文件到graph中
  53. tensorflow::GraphDef graph_def;
  54. status = ReadBinaryProto(Env::Default(), model_path, &graph_def);
  55. if (!status.ok()) {
  56. std::cerr << status.ToString() << endl;
  57. return -1;
  58. }
  59. else {
  60. cout << "Load graph protobuf successfully" << endl;
  61. }
  62. // 將graph加載到session
  63. status = session->Create(graph_def);
  64. if (!status.ok()) {
  65. std::cerr << status.ToString() << endl;
  66. return -1;
  67. }
  68. else {
  69. cout << "Add graph to session successfully" << endl;
  70. }
  71. // 輸入inputs,“ x_input”是我在模型中定義的輸入數據名稱
  72. std::vector<std::pair<std::string, tensorflow::Tensor>> inputs = {
  73. { "input_x:0", input_tensor },
  74. };
  75. // 輸出outputs
  76. //tensorflow::Tensor outputs(DT_FLOAT, TensorShape({ 1, height, width, depth }));
  77. std::vector<tensorflow::Tensor> outputs;
  78. //批處理識別
  79. for (int k = 0; k < 200; k++) {
  80. double start = clock();
  81. // 運行會話,計算輸出"x_predict",即我在模型中定義的輸出數據名稱,最終結果保存在outputs中
  82. status = session->Run(inputs, { "outimage:0" }, {}, &outputs);
  83. if (!status.ok()) {
  84. std::cerr << status.ToString() << endl;
  85. return -1;
  86. }
  87. else {
  88. cout << "Run session successfully" << endl;
  89. }
  90. // 下面進行輸出結果的可視化
  91. // 下面進行輸出結果的可視化
  92. tensorflow::Tensor output = std::move(outputs.at(0)); // 模型只輸出一個結果,這裏首先把結果移出來(也爲了更好的展示)
  93. auto out_shape = output.shape(); // 這裏的輸出結果爲1x4x16
  94. auto out_val = output.tensor<float, 4>(); // 與開頭的用法對應,4代表結果的維度
  95. cv::Mat out_image(height, width, CV_32FC(depth));
  96. float* data = (float*)out_image.data;
  97. for (int y = 0; y < height; ++y)
  98. {
  99. float* dataRow = data + (y * width * depth);
  100. for (int x = 0; x < width; ++x)
  101. {
  102. float* dataPixel = dataRow + (x * depth);
  103. for (int c = 0; c < depth; ++c)
  104. {
  105. float* dataValue = dataPixel + c;
  106. *dataValue = out_val(0, y, x, c);
  107. }
  108. }
  109. }
  110. cv::imshow("outimage", out_image);
  111. cv::waitKey(1);
  112. double finish = clock();
  113. double duration = (double)(finish - start) / CLOCKS_PER_SEC;
  114. cout <<"spend time:" << duration << endl;
  115. }
  116. /*cv::cvtColor(out_image, out_image, cv::COLOR_RGB2BGR);
  117. cv::cvtColor(out_image_final, out_image_final, cv::COLOR_RGB2BGR);
  118. cv::imwrite("E:/c++work/tf_testdemo/tf_testdemo/001_00045_out.png", out_image*255);
  119. cv::imwrite("E:/c++work/tf_testdemo/tf_testdemo/001_00045_out_final.png", out_image_final * 255);*/
  120. system("PAUSE");
  121. }

環境配置:

包含目錄:

E:\Users\tensorflow\bazel-source;E:\Users\tensorflow\bazel-source\external\org_tensorflow;E:\Users\tensorflow\bazel-source\external\protobuf_archive\src;E:\Users\tensorflow\bazel-source\external\com_google_absl;E:\Users\tensorflow\bazel-source\external\eigen_archive;E:\Users\tensorflow\bazel-source\bazel-out\x64_windows-opt\genfiles;E:\Users\tensorflow;E:\Opencv-vs2015\opencv342\include;E:\Opencv-vs2015\opencv342\include\opencv;E:\Opencv-vs2015\opencv342\include\opencv2;

E:\Users\tensorflow\bazel-source;E:\Users\tensorflow\bazel-source\external\org_tensorflow;E:\Users\tensorflow\bazel-source\external\protobuf_archive\src;E:\Users\tensorflow\bazel-source\external\com_google_absl;E:\Users\tensorflow\bazel-source\external\eigen_archive;E:\Users\tensorflow\bazel-source\bazel-out\x64_windows-opt\genfiles;E:\Users\tensorflow;E:\Opencv-vs2015\opencv342\include;E:\Opencv-vs2015\opencv342\include\opencv;E:\Opencv-vs2015\opencv342\include\opencv2;

庫目錄:

E:\Opencv-vs2015\opencv342\lib;E:\c++work\tf_testdemo\x64\Debug;

鏈接器輸入附加依賴項:

opencv_world342d.lib;opencv_world342.lib;tensorflow_cc.lib;

10.嘗試編譯debug版本

因爲項目需要,我自己也嘗試了編譯tensorflow的debug版本:

  1. $parameterString = "-c fastbuild --config=cuda --define=no_tensorflow_py_deps=true --copt=-nvcc_options=disable-warnings //tensorflow:libtensorflow_cc.so --verbose_failures"
  2. .\build.ps1 `
  3. -BazelBuildParameters $parameterString `
  4. -BuildCppAPI -ReserveSource -ReserveVenv

  1. $parameterString = "-c dbg--config=cuda --define=no_tensorflow_py_deps=true --copt=-nvcc_options=disable-warnings //tensorflow:libtensorflow_cc.so --verbose_failures"
  2. .\build.ps1 `
  3. -BazelBuildParameters $parameterString `
  4. -BuildCppAPI -ReserveSource -ReserveVenv

但是卡在了下面的錯誤

tensorflow::io::GetTempFilename

這個錯誤相關的github issue有這兩個issue1issue2和我自己開了一個issue,但是都建議編譯release version。所以這裏我暫停了繼續編譯debug版本。

11.遇到的問題

1.c++運行相同的pb模型,使用gpu,測試單張圖像速度比python慢?

python測試單張圖像20ms,c++測試單張圖像26ms;

相關issue:issue3,issue4.

2.編譯時遇到max的問題:

  1. string_view.h
  2. line491-493
  3. private:
  4. static constexpr size_type kMaxSize =
  5. std::numeric_limits<difference_type>::max();
  6. 改爲
  7. private:
  8. static constexpr size_type kMaxSize =
  9. (std::numeric_limits<difference_type>::max)();

 

 其他出錯的頭文件部分一一修改。

12.參考

[1]編譯windows tensorflowv1.11-1.13 dll release version

[2]cv輸入+tensorflow dll測試

[3]Tensorflow C++的Tensor和OpenCV的Mat相互轉換

[4]tensorflow_c++_api_1

[5]tensorflow_c++_api_2

[6]Mat <=> Tensor方法2

這裏非常感謝TerryBryant,給我解答問題,應用部分主要參考他的;也非常感謝guikarist分享的編譯方法。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章