编译安装飞桨fastdeploy@FreeBSD(失败)

2024-03-26 11:12

本文主要是介绍编译安装飞桨fastdeploy@FreeBSD(失败),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

FastDeploy是一款全场景易用灵活极致高效的AI推理部署工具, 支持云边端部署。提供超过 🔥160+ TextVisionSpeech跨模态模型📦开箱即用的部署体验,并实现🔚端到端的推理性能优化。包括 物体检测、字符识别(OCR)、人脸、人像扣图、多目标跟踪系统、NLP、Stable Diffusion文图生成、TTS 等几十种任务场景,满足开发者多场景、多硬件、多平台的产业部署需求。官网:GitHub - PaddlePaddle/FastDeploy: ⚡️An Easy-to-use and Fast Deep Learning Model Deployment Toolkit for ☁️Cloud 📱Mobile and 📹Edge. Including Image, Video, Text and Audio 20+ main stream scenarios and 150+ SOTA models with end-to-end optimization, multi-platform and multi-framework support.

遗憾的是在FreeBSD下没有装成。

发现fastdeploy需要opencv-python,所以花了很大的精力来安装,但是也没有装上。opencv可以用Pillow代替,但是后面还是碰到没法解决的问题。

编译安装opencv-python

编译安装没完成,估计还是用pkg install opencv-python装成的。

需要安装opencv-pyhton

安装opencv-python

pip install opencv-python,但是装不上,所以选择源代码编译安装

先安装pip install scikit-build

然后下载opencv-python源代码

可以用git clone https://github.com/opencv/opencv-python

也可以在pip安装的时候拿到下载链接,然后wget下载

https://mirror.baidu.com/pypi/packages/25/72/da7c69a3542071bf1e8f65336721b8b2659194425438d988f79bc14ed9cc/opencv-python-4.9.0.80.tar.gz

解压源代码:

tar -xzvf opencv-python-4.9.0.80.tar.gz

设置编译多线程:

set MAX_JOBS=8
export MAX_JOBS=8

开始编译

进入 opencv-python-4.9.0.80 目录并编译

cd  opencv-python-4.9.0.80
python setup.py install 

编译失败,见后面的记录。

安装FastDeploy

标准流程是cpu安装:pip install numpy opencv-python fastdeploy-python -f https://www.paddlepaddle.org.cn/whl/fastdeploy.html

我们使用命令

pip install fastdeploy-python -f https://www.paddlepaddle.org.cn/whl/fastdeploy.html

这样跳过了opencv部分,先把fastdeploy装好了。

推理

Python 推理示例

准备模型和图片

wget https://bj.bcebos.com/paddlehub/fastdeploy/ppyoloe_crn_l_300e_coco.tgz
tar xvf ppyoloe_crn_l_300e_coco.tgz
wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg

 python推理

# GPU/TensorRT部署参考 examples/vision/detection/paddledetection/python
import cv2
import fastdeploy.vision as visionmodel = vision.detection.PPYOLOE("ppyoloe_crn_l_300e_coco/model.pdmodel","ppyoloe_crn_l_300e_coco/model.pdiparams","ppyoloe_crn_l_300e_coco/infer_cfg.yml")
im = cv2.imread("000000014439.jpg")
result = model.predict(im)
print(result)vis_im = vision.vis_detection(im, result, score_threshold=0.5)
cv2.imwrite("vis_image.jpg", vis_im)

opencv-python这里实在装不上, 用Pillow代替,但是报错:

# GPU/TensorRT部署参考 examples/vision/detection/paddledetection/python
# import cv2
from PIL import Image
import fastdeploy.vision as visionmodel = vision.detection.PPYOLOE("ppyoloe_crn_l_300e_coco/model.pdmodel","ppyoloe_crn_l_300e_coco/model.pdiparams","ppyoloe_crn_l_300e_coco/infer_cfg.yml")
# im = cv2.imread("000000014439.jpg")
im =   Image.open("000000014439.jpg")
result = model.predict(im)
print(result)vis_im = vision.vis_detection(im, result, score_threshold=0.5)
# cv2.imwrite("vis_image.jpg", vis_im)
vis_im.save("vis_image.jpg")

结论:python推理失败

C++推理

预编译环境

Release版本

平台文件说明
Linux x64fastdeploy-linux-x64-1.0.7.tgzg++ 8.2编译产出
Windows x64fastdeploy-win-x64-1.0.7.zipVisual Studio 16 2019编译产出
Mac OSX x64fastdeploy-osx-x86_64-1.0.7.tgzclang++ 10.0.0编译产出

没有FreeBSD的,所以我们要自己编译。

进入FastDeploy目录进行编译:

cd FastDeploy
mkdri build && cd build 
cmake ..
make 

可以根据自己cpu的核数x,加上-j 2*x参数 ,如4核cpu  make -j 8

老规矩,编译好之后加入PATH路径,而不是放入/usr/bin目录,以免污染整个系统。

发现目录结构远比想像的要复杂,还是用make install 安装吧 。切换root账户,

cmake .. -DCMAKE_INSTALL_PREFIX=/home/xxx/work/fd
make -j 8 
make install 

最终使用的语句是在root账户下,在FastDeploy目录执行:

mkdir build
cd build/
cmake .. -DCMAKE_INSTALL_PREFIX=/home/skywalk/work/fd -DWITH_CAPI=ON
make -j 8
make install # 第一次运行报错,所以把下面的patch库挪到install
mkdir third_libs/install
cp -rf third_libs/patchelf/ third_libs/install/
make install

这里参数漏掉一个D ,加上之后编译不过去,也是就是DWITH_CAPI=ON编译不过去,ENABLE_PADDLE_BACKEND和ENABLE_ORT_BACKEND也都过不去。

把参数全删掉可以过去,但那样就没有用了啊!

结论:编译环境失败

准备图片

wget https://bj.bcebos.com/paddlehub/fastdeploy/ppyoloe_crn_l_300e_coco.tgz
tar xvf ppyoloe_crn_l_300e_coco.tgz
wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg

推理

源码

// GPU/TensorRT部署参考 examples/vision/detection/paddledetection/cpp
#include "fastdeploy/vision.h"int main(int argc, char* argv[]) {namespace vision = fastdeploy::vision;auto model = vision::detection::PPYOLOE("ppyoloe_crn_l_300e_coco/model.pdmodel","ppyoloe_crn_l_300e_coco/model.pdiparams","ppyoloe_crn_l_300e_coco/infer_cfg.yml");auto im = cv::imread("000000014439.jpg");vision::DetectionResult res;model.Predict(im, &res);auto vis_im = vision::VisDetection(im, res, 0.5);cv::imwrite("vis_image.jpg", vis_im);return 0;
}

把文件保存为infer_demo.c, 用gcc编译报错。

到FastDeploy/examples/runtime/cpp 目录,编译

mkdir build && cd build
cmake .. -DFASTDEPLOY_INSTALL_DIR=/home/skywalk/work/fd
make -j 8

(在没有任何参数的编译出来的环境下)编译出来一个runtime_demo文件,执行直接崩了。

结论

目前fastdeploy在FreeBSD没有调通。当然在linux下是极其好用的。

调试

pip install opencv-python报错

搞不定,下载源代码手动编译安装python setup.py install

编译时报错 No module named 'skbuild'

  File "/usr/home/skywalk/work/opencv-python-headless-4.9.0.80/setup.py", line 10, in <module>
    from skbuild import cmaker, setup
ModuleNotFoundError: No module named 'skbuild'

pip install scikit-build

编译安装时报错

[ 31%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/misc/caffe/opencv-caffe.pb.cc.o
In file included from /usr/home/skywalk/work/opencv-python-4.9.0.80/opencv/modules/dnn/misc/caffe/opencv-caffe.pb.cc:4:
In file included from /usr/home/skywalk/work/opencv-python-4.9.0.80/opencv/modules/dnn/misc/caffe/opencv-caffe.pb.h:10:
/usr/local/include/google/protobuf/port_def.inc:210:1: error: static_assert failed due to requirement '201103L >= 201402L' "Protobuf only supports C++14 and newer."
static_assert(PROTOBUF_CPLUSPLUS_MIN(201402L), "Protobuf only supports C++14 and newer.");
^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/home/skywalk/work/opencv-python-4.9.0.80/opencv/modules/dnn/misc/caffe/opencv-caffe.pb.cc:4:
/usr/home/skywalk/work/opencv-python-4.9.0.80/opencv/modules/dnn/misc/caffe/opencv-caffe.pb.h:17:2: error: This file was generated by an older version of protoc which is
#error This file was generated by an older version of protoc which is
 ^
/usr/home/skywalk/work/opencv-python-4.9.0.80/opencv/modules/dnn/misc/caffe/opencv-caffe.pb.h:18:2: error: incompatible with your Protocol Buffer headers. Please
#error incompatible with your Protocol Buffer headers. Please
  pip install protobuf==3.20试试

不行,用opencv-python4.4.

到openv目录 手工cmke .. make -j 报错

/usr/local/include/absl/strings/internal/has_absl_stringify.h:46:8: error: no template named 'enable_if_t' in namespace 'std'; did you mean simply 'enable_if_t'?
    T, std::enable_if_t<std::is_void<decltype(AbslStringify(
       ^~~~~
[  2%] Built target gen_opencv_python_source
/usr/local/include/absl/meta/type_traits.h:656:1: note: 'enable_if_t' declared here
using enable_if_t = typename std::enable_if<B, T>::type;
^
[  2%] Building CXX object 3rdparty/protobuf/CMakeFiles/libprotobuf.dir/src/google/protobuf/generated_message_table_driven_lite.cc.o
In file included from /home/skywalk/work/opencv-python-4.4.0.42/opencv/3rdparty/protobuf/src/google/protobuf/arena.cc:31:
In file included from /usr/local/include/google/protobuf/arena.h:53:
In file included from /usr/local/include/google/protobuf/arena_align.h:85:
/usr/local/include/google/protobuf/port_def.inc:210:1: error: static_assert failed due to requirement '201103L >= 201402L' "Protobuf only supports C++14 and newer."
static_assert(PROTOBUF_CPLUSPLUS_MIN(201402L), "Protobuf only supports C++14 and newer.");

尝试升级gcc:pkg upgrade gcc,但是也只升级到gcc13 还是不到14

尝试使用opencv-python3.4.17版本

报错

[ 45%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/misc/caffe/opencv-caffe.pb.cc.o
In file included from /usr/home/skywalk/work/opencv-python-3.4.17.63/opencv/modules/dnn/misc/caffe/opencv-caffe.pb.cc:4:
/usr/home/skywalk/work/opencv-python-3.4.17.63/opencv/modules/dnn/misc/caffe/opencv-caffe.pb.h:17:2: error: This file was generated by an older version of protoc which is
#error This file was generated by an older version of protoc which is
 ^
/usr/home/skywalk/work/opencv-python-3.4.17.63/opencv/modules/dnn/misc/caffe/opencv-caffe.pb.h:18:2: error: incompatible with your Protocol Buffer headers.  Please
#error incompatible with your Protocol Buffer headers.  Please
 ^
/usr/home/skywalk/work/opencv-python-3.4.17.63/opencv/modules/dnn/misc/caffe/opencv-caffe.pb.h:19:2: error: regenerate this file with a newer version of protoc.
#error regenerate this file with a newer version of protoc.

搞不定。

不过可喜的是,

import cv2没有报错,也就是opencv可以用啊!

后来测试,发现不行

编译opencv-python-headless报错

In file included from /usr/home/skywalk/work/opencv-python-headless-4.9.0.80/opencv/modules/dnn/misc/caffe/opencv-caffe.pb.cc:4:
In file included from /usr/home/skywalk/work/opencv-python-headless-4.9.0.80/opencv/modules/dnn/misc/caffe/opencv-caffe.pb.h:10:
/usr/local/include/google/protobuf/port_def.inc:210:1: error: static_assert failed due to requirement '201103L >= 201402L' "Protobuf only supports C++14 and newer."
static_assert(PROTOBUF_CPLUSPLUS_MIN(201402L), "Protobuf only supports C++14 and newer.");
^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

在root账户下fastdeploy c编译,make install 报错

-- Installing: /root/work/fd/include/fastdeploy/utils/path.h
CMake Error at cmake_install.cmake:81 (file):
  file INSTALL cannot find
  "/home/skywalk/github/FastDeploy/build/third_libs/install": No such file or
  directory.

尝试

cd ~/github/FastDeploy/build/third_libs

mkdir install
cp -rf patchelf/ install/
然后再make install

c推理例子编译报错:

skywalk@x250:~/github/FastDeploy/examples/runtime/cpp % gcc infer_demo.cc
In file included from /usr/local/include/fastdeploy/vision/visualize/visualize.h:17,
                 from /usr/local/include/fastdeploy/vision.h:78,
                 from infer_demo.cc:2:
/usr/local/include/fastdeploy/vision/common/result.h:16:10: fatal error: opencv2/core/core.hpp: No such file or directory
   16 | #include "opencv2/core/core.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
skywalk@x250:~/github/FastDeploy/examples/runtime/cpp %

examples/runtime/cpp目录编译生成的demo 文件runtime_demo执行报错:

./runtime_demo
[ERROR] fastdeploy/runtime/runtime.cc(105)::AutoSelectBackend    The candiate backends for ModelFormat::PADDLE & Device::CPU are [ Backend::PDINFER ,Backend::PDLITE ,Backend::ORT ,Backend::OPENVINO ], but both of them have not been compiled with current FastDeploy yet.
Assertion failed: (runtime.Init(runtime_option)), function main, file /home/skywalk/github/FastDeploy/examples/runtime/cpp/infer_paddle_paddle_inference.cc, line 37.
Abort (core dumped)

fastdeploy编译报错'opencv2/imgcodecs.hpp' file not found

type.cc.o
/home/skywalk/github/FastDeploy/c_api/fastdeploy_capi/core/fd_type.cc:17:10: fatal error: 'opencv2/imgcodecs.hpp' file not found
#include <opencv2/imgcodecs.hpp>
         ^~~~~~~~~~~~~~~~~~~~~~~

用Pillow替代opencv推理报错

python inf.py
Traceback (most recent call last):
  File "/usr/home/skywalk/py310/lib/python3.10/site-packages/fastdeploy_python-0.0.0-py3.10-freebsd-13.2-RELEASE-amd64.egg/fastdeploy/c_lib_wrap.py", line 164, in <module>
    from .libs.fastdeploy_main import *
ImportError: Shared object "libdl.so.2" not found, required by "libonnxruntime.so.1.12.0"

During handling of the above exception, another exception occurred:

先搁置。

这篇关于编译安装飞桨fastdeploy@FreeBSD(失败)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/848314

相关文章

Zookeeper安装和配置说明

一、Zookeeper的搭建方式 Zookeeper安装方式有三种,单机模式和集群模式以及伪集群模式。 ■ 单机模式:Zookeeper只运行在一台服务器上,适合测试环境; ■ 伪集群模式:就是在一台物理机上运行多个Zookeeper 实例; ■ 集群模式:Zookeeper运行于一个集群上,适合生产环境,这个计算机集群被称为一个“集合体”(ensemble) Zookeeper通过复制来实现

CentOS7安装配置mysql5.7 tar免安装版

一、CentOS7.4系统自带mariadb # 查看系统自带的Mariadb[root@localhost~]# rpm -qa|grep mariadbmariadb-libs-5.5.44-2.el7.centos.x86_64# 卸载系统自带的Mariadb[root@localhost ~]# rpm -e --nodeps mariadb-libs-5.5.44-2.el7

Centos7安装Mongodb4

1、下载源码包 curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.2.1.tgz 2、解压 放到 /usr/local/ 目录下 tar -zxvf mongodb-linux-x86_64-rhel70-4.2.1.tgzmv mongodb-linux-x86_64-rhel70-4.2.1/

Centos7安装JDK1.8保姆版

工欲善其事,必先利其器。这句话同样适用于学习Java编程。在开始Java的学习旅程之前,我们必须首先配置好适合的开发环境。 通过事先准备好这些工具和配置,我们可以避免在学习过程中遇到因环境问题导致的代码异常或错误。一个稳定、高效的开发环境能够让我们更加专注于代码的学习和编写,提升学习效率,减少不必要的困扰和挫折感。因此,在学习Java之初,投入一些时间和精力来配置好开发环境是非常值得的。这将为我

安装nodejs环境

本文介绍了如何通过nvm(NodeVersionManager)安装和管理Node.js及npm的不同版本,包括下载安装脚本、检查版本并安装特定版本的方法。 1、安装nvm curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash 2、查看nvm版本 nvm --version 3、安装

计算机毕业设计 大学志愿填报系统 Java+SpringBoot+Vue 前后端分离 文档报告 代码讲解 安装调试

🍊作者:计算机编程-吉哥 🍊简介:专业从事JavaWeb程序开发,微信小程序开发,定制化项目、 源码、代码讲解、文档撰写、ppt制作。做自己喜欢的事,生活就是快乐的。 🍊心愿:点赞 👍 收藏 ⭐评论 📝 🍅 文末获取源码联系 👇🏻 精彩专栏推荐订阅 👇🏻 不然下次找不到哟~Java毕业设计项目~热门选题推荐《1000套》 目录 1.技术选型 2.开发工具 3.功能

SWAP作物生长模型安装教程、数据制备、敏感性分析、气候变化影响、R模型敏感性分析与贝叶斯优化、Fortran源代码分析、气候数据降尺度与变化影响分析

查看原文>>>全流程SWAP农业模型数据制备、敏感性分析及气候变化影响实践技术应用 SWAP模型是由荷兰瓦赫宁根大学开发的先进农作物模型,它综合考虑了土壤-水分-大气以及植被间的相互作用;是一种描述作物生长过程的一种机理性作物生长模型。它不但运用Richard方程,使其能够精确的模拟土壤中水分的运动,而且耦合了WOFOST作物模型使作物的生长描述更为科学。 本文让更多的科研人员和农业工作者

K8S(Kubernetes)开源的容器编排平台安装步骤详解

K8S(Kubernetes)是一个开源的容器编排平台,用于自动化部署、扩展和管理容器化应用程序。以下是K8S容器编排平台的安装步骤、使用方式及特点的概述: 安装步骤: 安装Docker:K8S需要基于Docker来运行容器化应用程序。首先要在所有节点上安装Docker引擎。 安装Kubernetes Master:在集群中选择一台主机作为Master节点,安装K8S的控制平面组件,如AP

maven 编译构建可以执行的jar包

💝💝💝欢迎莅临我的博客,很高兴能够在这里和您见面!希望您在这里可以感受到一份轻松愉快的氛围,不仅可以获得有趣的内容和知识,也可以畅所欲言、分享您的想法和见解。 推荐:「stormsha的主页」👈,「stormsha的知识库」👈持续学习,不断总结,共同进步,为了踏实,做好当下事儿~ 专栏导航 Python系列: Python面试题合集,剑指大厂Git系列: Git操作技巧GO

衡石分析平台使用手册-单机安装及启动

单机安装及启动​ 本文讲述如何在单机环境下进行 HENGSHI SENSE 安装的操作过程。 在安装前请确认网络环境,如果是隔离环境,无法连接互联网时,请先按照 离线环境安装依赖的指导进行依赖包的安装,然后按照本文的指导继续操作。如果网络环境可以连接互联网,请直接按照本文的指导进行安装。 准备工作​ 请参考安装环境文档准备安装环境。 配置用户与安装目录。 在操作前请检查您是否有 sud