技术标签: paddlepaddle python 笔记 NLP实战项目 linux 深度学习
下载链接:
https://paddleinference.paddlepaddle.org.cn/user_guides/download_lib.html
在线下载
wget https://paddle-inference-lib.bj.bcebos.com/2.2.2/python/Linux/GPU/x86-64_gcc8.2_avx_mkl_cuda10.1_cudnn7.6.5_trt6.0.1.5/paddlepaddle_gpu-2.2.2.post101-cp37-cp37m-linux_x86_64.whl
pip install paddlepaddle_gpu-2.2.2.post101-cp37-cp37m-linux_x86_64.whl
或者直接
pip install https://paddle-inference-lib.bj.bcebos.com/2.2.2/python/Linux/GPU/x86-64_gcc8.2_avx_mkl_cuda10.1_cudnn7.6.5_trt6.0.1.5/paddlepaddle_gpu-2.2.2.post101-cp37-cp37m-linux_x86_64.whl
gcc版本也需要匹配一致
gcc安装参考链接:https://blog.csdn.net/qq_15821487/article/details/122886625?spm=1001.2014.3001.5502
TensorRT是Nvidia公司出的能加速模型推理的框架,其实就是让你训练的模型在测试阶段的速度加快,比如你的模型测试一张图片的速度是50ms,那么用tensorRT加速的话,可能只需要10ms。当然具体能加速多少也不能保证,反正确实速度能提升不少。
参考文章:
https://blog.csdn.net/feedinglife/article/details/120848119
https://zhuanlan.zhihu.com/p/88318324
https://tbr8.org/how-to-install-tensorrt-on-centos/
paddle官方文档:https://paddleinference.paddlepaddle.org.cn/product_introduction/inference_intro.html
TensorRT官方文档:
https://docs.nvidia.com/deeplearning/tensorrt/index.html
TensorRT官方github:
https://github.com/NVIDIA/TensorRT
https://developer.nvidia.com/nvidia-tensorrt-download
填个问卷,然后直接点击进来即可
鼠标右键
1、
wget https://developer.download.nvidia.cn/compute/machine-learning/tensorrt/secure/6.0/GA_6.0.1.5/tars/TensorRT-6.0.1.5.CentOS-7.6.x86_64-gnu.cuda-10.1.cudnn7.6.tar.gz?bjNJHRorOM7wGWYqRC6WNq1Yc5t7qnfDjp0623k5RYOwiHURX7Wn4LGKTjbI_qGQxKPeyZW9uxElmQnnBibKtdNpFWRWcwcdmVKOiCqzXFdawKSqUWj6NlLAFOK8ipKe5XOG8QrgntKTRPsDtKVvlG-yL1BLkxj7KTcTCP5jmu3ezMgAisSZ4lGoNvONTME-wi3MnfXx0obnjy5iu_vmAg1sJohJnXwZ73Fxim-5p71edW_bSeKbzM9VPmU&t=eyJscyI6InJlZiIsImxzZCI6IlJFRi1kb2NzLm52aWRpYS5jb21cLyJ9
快速查找某个文件:
find / -name "TensorRT*"
2、
tar xzvf TensorRT-6.0.1.5.CentOS-7.6.x86_64-gnu.cuda-10.1.cudnn7.6.tar.gz
3、下载完后,解压,接着 vi ~/.bashrc,添加如下内容
其中/home/andy/TensorRT替换成你自己实际的目录,cuda-9.0也是。
vim ~/.bashrc
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/trt/TensorRT-6.0.1.5/lib:/usr/local/cuda-10.1/lib64
source ~/.bashrc
4、然后就是安装对应的python库,包括tensorRT,uff和graphsurgeon
cd /opt/trt/TensorRT-6.0.1.5/python
pip3 install tensorrt-6.0.1.5-cp37-none-linux_x86_64.whl
cd /opt/trt/TensorRT-6.0.1.5/uff
pip3 install uff-0.6.5-py2.py3-none-any.whl
cd /opt/trt/TensorRT-6.0.1.5/graphsurgeon
pip3 install graphsurgeon-0.4.1-py2.py3-none-any.whl
5、搞定后,进到python环境下,执行下import tensorrt,正常的话可以成功导入。
import tensorrt
tensorrt.__version__
'6.0.1.5
6、最后可以编译一下tensorRT提供的一些sample。进到tensorRT的sample目录下,执行make CUDA_INSTALL_DIR=/usr/local/cuda,完成后到tensorRT的bin目录下,可以看到已经生成了可执行的sample,执行./sample_mnist 就可以输出一副字符组成的数字图片,下面跟着mnist的预测结果。 ok整个安装搞定了。
cd /opt/trt/TensorRT-6.0.1.5/samples
make CUDA_INSTALL_DIR=/usr/local/cuda
cd /opt/trt/TensorRT-6.0.1.5/bin
./sample_mnist
7、查看版本号
find / -name NvInferVersion.h
服务端:
python web_service.py
客户端:
python rpc_client.py
时间 :0.15128087997436523s
服务端:
python web_service.py
客户端:
python rpc_client.py
时间加速明显 :
第一次运行加载:3s
后面每次:0.028s
时间发现没有提速 :
第一次运行加载:3s
后面每次:0.028s
https://hub.fastgit.org/PaddlePaddle/Serving/blob/v0.7.0/doc/Serving_Configure_CN.md#python-pipeline
python predict.py
时间:1.45s
python predict.py --enable_mkldnn=True
时间:1.45s 基本无变化
python predict.py --device=gpu
时间:7.35 时间反而更长,时间花费在加载模型
python predict.py --device=gpu --use_tensorrt=True
报错
Traceback (most recent call last):
File "predict.py", line 282, in <module>
args.cpu_threads, args.enable_mkldnn)
File "predict.py", line 151, in __init__
self.predictor = paddle.inference.create_predictor(config)
ValueError: (InvalidArgument) Pass trt_squeeze2_matmul_fuse_pass has not been registered.
[Hint: Expected Has(pass_type) == true, but received Has(pass_type):0 != true:1.] (at /paddle/paddle/fluid/framework/ir/pass.h:240)
报错解决方案,需要安装特定版本的paddle带trt的paddle
报错2:
E0216 17:04:09.163729 30082 helper.h:111] Parameter check failed at: ../builder/Network.cpp::addInput::671, condition: isValidDims(dims, hasImplicitBatchDimension())
运行报错,查看日志
CRITICAL 2022-02-16 19:29:49,479 [operator.py:1315] [ernie|0] failed to init op: (InvalidArgument) Adding input reshape2_60.tmp_0 failed in TensorRT inference network. Please recheck your input.
[Hint: input should not be null.] (at /paddle/paddle/fluid/inference/tensorrt/engine.cc:266)
Traceback (most recent call last):
File "/data/mart/neural_search/venv/lib/python3.7/site-packages/paddle_serving_server/pipeline/operator.py", line 1308, in _run
concurrency_idx)
File "/data/mart/neural_search/venv/lib/python3.7/site-packages/paddle_serving_server/pipeline/local_service_handler.py", line 228, in get_client
mkldnn_bf16_op_list=self._mkldnn_bf16_op_list)
File "/data/mart/neural_search/venv/lib/python3.7/site-packages/paddle_serving_app/local_predict.py", line 235, in load_model_config
self.predictor = paddle_infer.create_predictor(config)
ValueError: (InvalidArgument) Adding input reshape2_60.tmp_0 failed in TensorRT inference network. Please recheck your input.
[Hint: input should not be null.] (at /paddle/paddle/fluid/inference/tensorrt/engine.cc:266)
文章浏览阅读395次。阅读目录: 1.开篇介绍 2.ASP.NETMVC IControllerFactory 控制器工厂接..._controllerbuilder.current.setcontrollerfactory
文章浏览阅读1.5k次。背景知识图简介图由节点和边组成,边有方向的图称为有向图,边没有方向的图称为无向图,最短路径算法里可以把无向图视为双向连接的有向图。 边有权重的图称为有权图,边没有权重的图称为无权图,无权图可以视为边的权重均为1的图。单源点最短路径给定图中的一个节点,求该节点到其他所有节点的最短路径。Bellman-Ford算法概述Bellman-Ford属于DP算法,_bellman-ford算法是多边dp吗
文章浏览阅读248次。安装php扩展。_pecl install xlswriter
文章浏览阅读8.4k次,点赞6次,收藏21次。SQL Server configuration manager is a tool provided by Microsoft SQL Server. When we install SQL Server, it is installed automatically. It is used for the following purposes. SQL Server配置管理器是Mic..._sql native client 11.0 配置客户端协议
文章浏览阅读1.1k次。所以今天小编给大家分享4个微软官方推出的实用工具,每一个都非常好用,对于大家日常办公,非常有必要,感兴趣的朋友可以下载试试!_微软资源库
文章浏览阅读1.6k次。其实去年就已经把Android上OpenCL的demo做出来了,但是由于种种原因一直没有开源–嗯现在就不吝啬了~奉献给大家~后面在Android上还实现了很多种并行化的算法,比如SHA-1、HDR、K-means、NL-means、SRAD等等,会在近期整理好之后开源的。原文发表在了异构开发技术社区整理成教程是队友做的,十分感谢~原博文地址: 原文链接已经失效,无法查看了,好遗憾队友的博客项目github地址代码CSDN地址下面是干货:Android平台利用OpenCL框架实现并行._cl社区1024地址
文章浏览阅读747次,点赞35次,收藏45次。v-cloak 是一个实用的 Vue 指令,它可以在页面加载期间防止用户看到未编译的 Vue 代码。当使用 v-cloak 时,通常会结合 CSS 规则来确保在 Vue 编译过程完成之前,用户看不到任何预编译的内容。这包括防止大括号 {{ }} 和其他模板语法在页面上闪烁。_v-cloak作用
文章浏览阅读1.9k次,点赞2次,收藏3次。最近使用idea后台开发功能,启动tomcat时报错,具体错误如下:Error:java: Compilation failed: internal java compiler error百度了一些文章,不过都不管用!!!!!!我的解决方案如下:在setting-->Build,Execution,Deployment-->Compiler 中找到build process hea..._tomcat compilation failed internal java compiler error
文章浏览阅读1.3k次。Ubuntu安装CodeChecker首先环境使用的是Ubuntu16.04发行版其自带的python版本为3.5,gcc版本为5CodeChecker需要python版本>=3.6经过实验,发现Ubuntu版本过低时,如果不能按照如下方法使用apt直接安装python,那么需要使用gcc对python源码进行进行编译安装。此时gcc版本应至少>=5。否则无法对python进行编译安装(至少gcc4.8.1不行)因此如果需要gcc降级,那么务必在安装CodeChecker安装结束后再_ubuntu codechecker
文章浏览阅读1.6w次,点赞12次,收藏108次。文章目录Mapper.xml 详解1. parameterType2. resultType3. 级联查询3.1 一对多3.2 多对多Mapper.xml 详解MyBatis 主要有两个的配置文件:config.xml 和 Mapper.xml,这两个配置文件可以自定义文件名。config.xml 是全局配置文件,主要配置 MyBatis 的数据源(DataSource),事务管理(TransactionManager)以及打印 SQL 语句,开启二级缓存,注册 Mapper.xml 等。Map_mapper.xml
文章浏览阅读2.4w次,点赞30次,收藏61次。太久没有使用模拟器,今天突然打不开抓包工具了,莫慌,马上上解决方法。出现这个问题的原因可能是因为各位老铁们在升级软件的时候位置变了,或者是先安装了ensp后面才安装的wireshark。解决方法:单击 eNSP的菜单 - 工具 - 选项 - 工具设置,在引用工具里面 设置你安装的 wireshark 路径。有的老铁可能已经忘记了安装路径,这边告知大家如何找到安装路径,先找到电脑里面的wireshark请注意看一下是不是真实的安装路径如果不是请同理选中快捷方式右键选中打开文件所在位置下_ensp抓包工具wireshark配置路径不正确
文章浏览阅读132次。阿里 P8 大佬的架构笔记:微服务分布式架构实践手册从企业的真实需求出发,理论结合实际,深入讲解 Spring Cloud 微服务和分布式系统的知识。_阿里p8分布式架构笔记