windows 构建 tensorflow lite 库文件

windows 构建 tensorflow lite 库文件,第1张

目录
  • 构建工具
  • 准备工作
  • 开始构建
  • 报错问题
    • ERROR: C:/users/dell/_bazel_dell/sjuogcx5/external/XNNPACK/BUILD.bazel:5629:19: C++ compilation of rule '@XNNPACK//:indirection' failed (Exit 1): vc_installation_error.bat failed: error executing command
    • 连接库的时候报找不到`flatbuffers.h`
  • 参考

构建工具

tensorflow
https://github.com/tensorflow/tensorflow/tree/r2.6

Visual Studio 2019 自行在网上下载

msys2
https://www.msys2.org/

bazel 3.7.2
https://github.com/bazelbuild/bazel/releases?q=3.7.2&expanded=true

python 3.7.6
https://www.python.org/downloads/release/python-372/

工具版本一定要对应,不然会构建失败

准备工作

将msys2 和 bazel添加到环境变量
打开cmd
测试python是否添加成功:

python --version

测试msys2是否添加成功:

pacman --version

测试bazel是否添加成功:

bazel --version

有输出则为成功

开始构建

在cmd中输入

pacman -S git patch unzip

进入tensorflow目录,输入

python configure.py


让输入Y/n则输入n就可以了
空白就输入回车键

输入

bazel build -c opt --config=mkl //tensorflow/lite:tensorflowlite.dll

开始编译

编译成功输出

在tensorflow目录下多出一个bazel-out文件夹
\bazel-out\x64_windows-opt\bin\tensorflow\lite
进入到这个路径下
tensorflowlite.dlltensorflowlite.dll.if.lib则是我们需要的库文件
头文件则在tensorflow/lite目录
工程连接到这个目录就行了

报错问题 ERROR: C:/users/dell/_bazel_dell/sjuogcx5/external/XNNPACK/BUILD.bazel:5629:19: C++ compilation of rule ‘@XNNPACK//:indirection’ failed (Exit 1): vc_installation_error.bat failed: error executing command

因为bazel找不到vs导致的
找到你的vs2019安装路径(我的安装路径是D:\compiler\vs2019)
里面有个VC文件夹就是正确的
在cmd中输入:

set BAZEL_VC=D:\compiler\vs2019\VC
连接库的时候报找不到flatbuffers.h

在tensorflow 里找到这个路径bazel-out\x64_windows-opt\bin\external\flatbuffers\src\_virtual_includes\flatbuffers
工程连接这个路径

参考

https://www.tensorflow.org/install/source_windows
https://blog.csdn.net/huachao1001/article/details/111995685

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/875793.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-13
下一篇2022-05-13

发表评论

登录后才能评论

评论列表(0条)

    保存