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

先搁置。

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Gemma开源AI指南

近几个月来&#xff0c;谷歌推出了 Gemini 模型&#xff0c;在人工智能领域掀起了波澜。 现在&#xff0c;谷歌推出了 Gemma&#xff0c;再次引领创新潮流&#xff0c;这是向开源人工智能世界的一次变革性飞跃。 与前代产品不同&#xff0c;Gemma 是一款轻量级、小型模型&…

1升级powershell后才能安装WSL2--最后安装linux--Ubuntu 22.04.3 LTS

视频 https://www.bilibili.com/video/BV1uH4y1W7UX特殊开启–Hyper-V虚拟机 把一下代码保存到【a.bat】的执行文件中&#xff0c;进行Hyper-V虚拟机的安装开启【Windows 批处理文件 (.bat)】 pushd "%~dp0" dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mu…

鸿蒙Harmony跨模块交互

1. 模块分类介绍 鸿蒙系统的模块一共分为四种&#xff0c;包括HAP两种和共享包两种 HAP&#xff08;Harmony Ability Package&#xff09; Entry&#xff1a;项目的入口模块&#xff0c;每个项目都有且只有一个。feature&#xff1a;项目的功能模块&#xff0c;内部模式和En…

(已解决)vue3使用富文本出现样式乱码

我在copy代码到项目里面时候发现我的富文本乱码了 找了一圈不知道是哪里vue3不适配还是怎么&#xff0c;后来发现main.js还需要引入 import VueQuillEditor from vue-quill-editor // require styles 引入样式 import quill/dist/quill.core.css import quill/dist/quill.snow…

YOLOv9代码解读[01] readme解读

文章目录 YOLOv9COCO数据集上指标&#xff1a;环境安装训练验证重参数化 Re-parameterization推断相关链接 YOLOv9 paper: YOLOv9: Learning What You Want to Learn Using Programmable Gradient Information github: https://github.com/WongKinYiu/yolov9 COCO数据集上指…

网络安全笔记-day8,DHCP部署

DHCP部署与安全 全称&#xff08;Dynamic Host Configura Protocol&#xff09;动态主机配置协议 DHCP原理 DHCP协议_科来测试dhcp网络包-CSDN博客&#x1f50d; 注意的是利用广播地址发送包 ACK&#xff08;确认&#xff09; 如果DHCP服务器损坏&#xff0c;则在87.5%时…

Open WebUI大模型对话平台-适配Ollama

什么是Open WebUI Open WebUI是一种可扩展、功能丰富、用户友好的大模型对话平台&#xff0c;旨在完全离线运行。它支持各种LLM运行程序&#xff0c;包括与Ollama和Openai兼容的API。 功能 直观的界面:我们的聊天界面灵感来自ChatGPT&#xff0c;确保了用户友好的体验。响应…

线性代数 - 应该学啥 以及哪些可以交给计算机

AI很热&#xff0c;所以小伙伴们不免要温故知新旧时噩梦 - 线代。 &#xff08;十几年前&#xff0c;还有一个逼着大家梦回课堂的风口&#xff0c;图形学。&#xff09; 这个真的不是什么美好的回忆&#xff0c;且不说老师的口音&#xff0c;也不说教材的云山雾绕&#xff0c;单…

【考研数学二】线性代数重点笔记

目录 第一章 行列式 1.1 行列式的几何意义 1.2 什么是线性相关&#xff0c;线性无关 1.3 行列式几何意义 1.4 行列式求和 1.5 行列式其他性质 1.6 余子式 1.7 对角线行列式 1.8 分块行列式 1.9 范德蒙德行列式 1.10 爪形行列式的计算 第二章 矩阵 2.1 初识矩阵 2…

查看VMWare ESXi 6.5/6.7服务器上 GPU直通的状态

VMWare ESXi 6.5/6.7服务器状态 查看配置参数

生物信息学 GO、KEGG

文章目录 北大基因本体论分子通路KEGGGO注释分子通路鉴定 关于同源 相似性 b站链接&#xff1a;北大课程 概述了当前生物信息学领域中几个重要的概念和工具&#xff0c;介绍基因本体论&#xff08;Gene Ontology, GO&#xff09;、分子通路知识库KEGG&#xff08;Kyoto Encyclo…

纯前端调用本机原生Office实现Web在线编辑Word/Excel/PPT,支持私有化部署

在日常协同办公过程中&#xff0c;一份文件可能需要多次重复修改才能确定&#xff0c;如果你发送给多个人修改后再汇总&#xff0c;这样既效率低又容易出错&#xff0c;这就用到网页版协同办公软件了&#xff0c;不仅方便文件流转还保证不会出错。 但是目前一些在线协同Office…

go的for循环应该这么用

目录 目录 一&#xff1a;介绍 1: for流程控制 2&#xff1a;for-range流程控制 二&#xff1a;实例展示 1&#xff1a;//按照一定次数循环 2&#xff1a;//无限循环 3: //循环遍历整数、各种容器和通道 4&#xff1a;遍历通道 5&#xff1a;//指针数组循环 6&…

Pillow教程05:NumPy数组和PIL图像的相互转化

---------------Pillow教程集合--------------- Python项目18&#xff1a;使用Pillow模块&#xff0c;随机生成4位数的图片验证码 Python教程93&#xff1a;初识Pillow模块&#xff08;创建Image对象查看属性图片的保存与缩放&#xff09; Pillow教程02&#xff1a;图片的裁…

SpringBoot 文件上传(三)

之前讲解了如何接收文件以及如何保存到服务端的本地磁盘中&#xff1a; SpringBoot 文件上传&#xff08;一)-CSDN博客 SpringBoot 文件上传&#xff08;二&#xff09;-CSDN博客 这节讲解如何利用阿里云提供的OSS&#xff08;Object Storage Service)对象存储服务保存文件。…

vite5+vue3+ import.meta.glob动态导入vue组件

import.meta.glob 是 Vite 提供的一个特殊功能&#xff0c;它允许你在模块范围内动态地导入多个模块。这在处理大量的文件&#xff0c;如组件、页面或其他模块时特别有用&#xff0c;特别是当你需要根据某些条件或模式来动态加载它们时。 1.创建需要动态导入的组件目录 假设你…

设计模式—观察者模式与发布订阅

观察者设计模式 观察者设计模式&#xff08;Observer Design Pattern&#xff09;是一种常用的软件设计模式&#xff0c;它是一种行为型模式。该模式用于定义对象之间的一种一对多的依赖关系&#xff0c;当一个对象的状态发生改变时&#xff0c;所有依赖于它的对象都将得到通知…

FTP 文件传输服务

FTP连接 控制连接&#xff1a;TCP 21&#xff0c;用于发送FTP命令信息 数据连接&#xff1a;TCP 20&#xff0c;用于上传、下载数据 数据连接的建立类型&#xff1a; 主动模式&#xff1a;服务端从 20 端口主动向客户端发起连接 被动模式&#xff1a;服务端在指定范围…

flask_restful数据解析

参数验证也叫参数解析 Flask-Restful 插件提供了类似 WTForms 来验证提交的数据是否合法 的包&#xff0c;叫做 reqparse 。 # Flask_RESTFUl数据解析 from flask import Flask,render_template from flask_restful import Api,Resource from flask_restful.reqparse import …

项目3-留言板

1.创建项目 记得将project type改为maven 将需要的包引入其中 更改版本号 引入MYSQL相关包记得进行配置&#xff01;&#xff01;&#xff01; spring:datasource:url: jdbc:mysql://127.0.0.1:3306/mycnblog?characterEncodingutf8&useSSLfalseusername: rootpassword:…