编译安装飞桨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 vision

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")
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 vision

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")
# 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:

先搁置。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/497157.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

上传镜像到仓库

上传镜像到公开仓库 1、给要上传的镜像打标签 # 从206节点上传镜像到仓库&#xff08;201&#xff09;magedu项目&#xff0c;查看206镜像 [rootk8s-node2 ~]# docker images REPOSITORY TAG IMAGE ID CRE…

arp 协议

数据链路层 我们之前学习到的 IP 协议解决的是数据跨网络传输的问题。 数据链路层解决的是&#xff1a;直接相连的主机&#xff0c;进行数据交付的问题&#xff01; 直接相连的设备包括我们的电脑&#xff0c;路由器等等哈&#xff01; 我们在网络基础那篇文章中讲过什么是以…

OneDiff加速“图生生”,解锁电商AI图像处理新范式

2024年&#xff0c;电商领域正目睹生成式AI软件工具的飞速发展&#xff0c;AI Generated Content (AIGC) 技术在电商应用中的普及率正在显著提升&#xff0c;这类技术能够显著提高商业运营的效率&#xff0c;并促进业绩的稳步增长。 硅基流动研发的图片/视频生成推理引擎OneDif…

近线数仓优化改造

近线数仓优化改造 1. 背景2. 优化3. 改造3.1. 重构3.2. 优化 1. 背景 大概就是有那么一个数仓&#xff0c;然后简略结构如下&#xff1a; #mermaid-svg-PVoUzuQhj2BK7Qge {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid…

Linux系统中的软件管理

如何让虚拟机上网 # 1.Linux中软件包的类型 # &#xff08;1&#xff09;DEB #UBlinux DEBlinux &#xff08;2&#xff09;RPM #redhat centOS fadora &#xff08;3&#xff09;bz2|gz|xz #1.需要源码安装需要编译 #2.绿色软件&…

PDFgear:一款免费的PDF编辑、格式转化软件

日常办公中&#xff0c;很多朋友都会接触到PDF文件。把文件转化成PDF是保留文件格式、防范别人修改常用的方法。但是很多人会为PDF文件的生成、压缩、编辑和格式转化而头疼&#xff0c;还有人为了能把PDF转化成Word还购买了不少付费的软件。 为了解决大家这个痛点&#xff0c;…

2024 ccfcsp认证打卡 2023 03 02 垦田计划

import java.util.*;public class Main {public static void main(String[] args) {Scanner input new Scanner(System.in);int N 100100; // 定义一个较大的常数Nlong[] t new long[N]; // 存储任务的耗时long[] c new long[N]; // 存储每块区域投入资源的数量long[] c…

【推导结果】如何得到 回归均方误差 估计系数的标准误

对线性回归模型系数标准差标准误的理解 1.生成数据 yxe3.610.633.42-1.387.631.017.44-1.0111.651.3811.46-0.63 2.回归 y β 0 β 1 x ϵ y \beta_{0}\beta_{1}x\epsilon yβ0​β1​xϵ y i β 0 β 1 x i e i y_{i}\beta_{0}\beta_{1} x_{i}e_{i} yi​β0​β1​xi…

Linux第84步_了解Linux中断及其函数

1、中断号 中断号又称中断线&#xff0c;每个中断都有一个中断号&#xff0c;通过中断号即可区分不同的中断。 2、Linux中断API函数 需要包含头文件“#include <linux/interrupt.h>” 1)、在使用某个中断功能的时候&#xff0c;需要执行“申请中断” int request_irq(…

如何压缩视频到最小?教会你压缩原理~

在网上上传视频时&#xff0c;经常会遇到因为视频体积过大上传失败等情况发生&#xff0c;怎么降低视频体积呢&#xff1f;科普一个小知识&#xff1a;视频体积和视频的时长、编码格式、分辨率和比特率&#xff08;又称码率&#xff09;有关。视频文件大小计算公式&#xff1a;…

掼蛋怎么开牌

一、强牌出单张 1、只有打完小单张&#xff0c;才能争得头游。特别是有两三手小牌&#xff0c;必须要先出掉一两手。 2、首发单张&#xff0c;特别是5以下的小单牌&#xff0c;即先打小牌。表明是强牌。尤其是在贡牌后首发小单牌&#xff0c;属于“明知山有虎&#xff0c;偏向…

13.Java能干什么?以及Java的三大平台

文章目录 一、JavaSE二、JavaME三、JavaEE JAVA从95年以来&#xff0c;已经问世了20多年了&#xff0c;可能比部分同学的年龄还大。 Java到底能干嘛呢&#xff0c;此时就需要讲到Java的三大平台&#xff0c;其实也就是它的三个分类&#xff1a;JavaSE、JavaME、JavaEE。 一、Ja…

【Web应用技术基础】CSS(5)——表格样式

第一题&#xff1a;表格边框 .html <!DOCTYPE html> <html><head><meta charset"UTF-8" /><title>HTML – 简单表格</title><link rel"stylesheet" href"step1/CSS/style.css"></head><bod…

Git 命令总览

Git Git 是一个版本控制系统&#xff0c;用于管理项目代码。通过 Git 可以轻松地进行代码的提交、更新和合并&#xff0c;确保项目代码的安全性和稳定性。同时&#xff0c;Git 还提供了丰富的工具和功能&#xff0c;如分支管理、代码审查、版本回退等&#xff0c;帮助开发更好…

docker容器内存检测排查

查询容器使用内存 在运维当中&#xff0c;你会发现内存很彪的高&#xff0c;但是如何判断为什么会高&#xff0c;是什么样的程序造成的呢&#xff1f;赶快使用 top&#xff0c;或者 free -h或者 ps -v。是吗&#xff1f;道理是对的。 但是你会发现&#xff0c;全部都是docker…

Java_19 罗马数字转整数

罗马数字转整数 罗马数字包含以下七种字符: I&#xff0c; V&#xff0c; X&#xff0c; L&#xff0c;C&#xff0c;D 和 M。 字符 数值 I 1 V 5 X 10 L 50 C 100 D 500 M 1…

如何扫码登记信息?二维码登记信息更加简单快捷

现在很多场所会通过生成二维码的方式来做人员信息登记或者人员签到&#xff0c;那么这种扫描二维码填写信息的制作技巧是什么样的呢&#xff1f;想要做出这种效果&#xff0c;那么需要生成表单二维码&#xff0c;准备好问题和说明&#xff0c;通过专业工具的功能就可以轻松完成…

Redis中的LRU算法分析

LRU算法 概述 Redis作为缓存使用时&#xff0c;一些场景下要考虑内容的空间消耗问题。Redis会删除过期键以释放空间&#xff0c;过期键的删除策略 有两种: 1.惰性删除:每次从键空间中获取键时&#xff0c;都检查取得的键是否过期&#xff0c;如果过期的话&#xff0c;就删除…

轻松上手,小白也能免费部署自己的炫酷静态网站!(如何免费搭建个人网站)

文章目录 📖 介绍 📖🏡 演示环境 🏡📒 使用方法 📒📝 操作步骤📝 更换主题⚓️ 相关链接 ⚓️📖 介绍 📖 在互联网时代,拥有一个个人网站无疑是展示自我、分享知识或建立品牌形象的有效途径。然而,许多人在追求这一目标的过程中,常常因为成本、时间和技…

【C++】1320. 时钟旋转(1)

问题 类型&#xff1a;整数运算 题目描述&#xff1a; 时钟上面的时针从 m 时走到 n 时旋转了多少度&#xff1f;&#xff08;m≤n&#xff0c;且 m 和 n 都是1∼12之间的整数&#xff09;。 输入&#xff1a; 2 个整数 m 和 n。 输出&#xff1a; 1 个整数代表时针旋转的…