
pytorch技巧
丶Shining
深度学习爱好者,深度学习部署优化。
Github:https://github.com/xxradon;
Mail:wangdong_cn@qq.com
展开
-
TensorRT5,TensorRT6不兼容pytorch1.2,1.3,1.4导出的ONNX模型解决方案
错误点使用pytorch1.2,1.3导出的ONNX模型,如下面这个resnet18的代码:import torchimport torch.nn as nnimport mathdummy_input = torch.randn(10, 3, 224, 224, device='cuda')def conv3x3(in_planes, out_planes, strid...原创 2020-01-13 16:27:08 · 9911 阅读 · 7 评论 -
pytorch初始化时占用过多内存问题
问题来源:使用pytorch部署代码,我们会发现一个问题,就是如果只是使用cpu不适用gpu,pytorch加载进来的时候并不会占用多大的内存,一切都是正常的。下面是问题描述:There is a huge RAM overhead for using the GPU even for processing small tensors.Here’s a standalone script...原创 2020-01-09 14:40:18 · 5751 阅读 · 0 评论 -
pytorch内部机制解读
斯坦福大学博士生与 Facebook 人工智能研究所研究工程师 Edward Z. Yang 是 PyTorch 开源项目的核心开发者之一。本文是对Mr. Yang写的关于pytorch内部机制的博文的总结,该文编写时pytorch版本估计为0.3,此时pytorch的tensor和Viarable还没完全合并。原文地址:http://blog.ezyang.com/2019/05/pytorc...转载 2020-01-08 18:56:22 · 535 阅读 · 0 评论 -
pytorch推理时将prelu转成relu实现
很多时候,我们的推理框架如,tensorrt,支持relu实现,但是不支持Prelu。此时我发现了该项目https://github.com/PKUZHOU/MTCNN_FaceDetection_TensorRT,其中说道:Considering TensorRT don't support PRelu layer, which is widely used in MTCNN, one so...原创 2019-12-16 13:54:44 · 1862 阅读 · 0 评论 -
pytorch1.2,pytorch1.3如何使用1.1及以前生成的script(.pt)文件
pytorch自从1.2版本以后,主要的数据结构上面的变化就是增加了bool变量,所以以前的uint8输入需要更改一下。不解压,使用压缩工具软件,如rar,打开.pt文件,如图。找到里面的code/xray.py文件,这里面记录的就是我们的静态图,所有的参数都是固定写好的。将dtype=0 的改为dtype=11下面是c10/core/ScalarType.h中定义的顺序#define...原创 2019-12-10 17:12:54 · 1352 阅读 · 0 评论 -
Pytorch1.0.1导出ONNX模型
TORCH.ONNXExample: End-to-end AlexNet from PyTorch to Caffe2这是一个简单的脚本,它将torchvision中定义的预训练的AlexNet导出到ONNX中。它运行一轮推理,然后将生成的跟踪模型保存到alexnet.onnx:mport torchimport torchvisiondummy_input = torch.rand...原创 2019-07-15 09:41:55 · 4528 阅读 · 0 评论 -
PyTorch for Jetson Nano/TX2
来源:https://devtalk.nvidia.com/default/topic/1049071/jetson-nano/pytorch-for-jetson-nano/Below are pre-built PyTorch 1.1 pip wheel installers for Python 2.7 and Python 3.6 on Jetson Nano, Jetson TX2, ...原创 2019-04-09 20:16:01 · 3759 阅读 · 1 评论 -
pytorch C++ API 与TensorRT的冲突
2019.3.26TensorRT的例子中,用到的公共头文件common.h,// 如果使用CHECK,会跟pytorch中的源码冲突#define CHECK(status) \ do \ { ...原创 2019-03-26 17:24:49 · 1154 阅读 · 0 评论 -
pytorch1.0,1.0.1-- onnx --tensorRT5.0.2.6的upsample_nearest2d BUG
最近英伟达发布了一个开源项目,https://github.com/NVIDIA/retinanet-examples,查看源码我们发现在RetinaNet/model.py 中将将pytorch的pth模型转化为onnx时,代码中有这样一段代码: import torch.onnx.symbolic # Override Upsample's ONNX expo...原创 2019-03-25 19:03:00 · 3420 阅读 · 1 评论 -
Hi3559A 开发总结--使用docker
Hi3559A的芯片资源这里可以清晰看到,CPU部分无非是A73和A53,跑的系统还是linux,architecture都是"aarch64"。所以有了一个想法,就是呢,我使用RK3399的ubuntu系统编译了一个小程序,只有print函数的,生成可执行程序,移植到3559A上运行,一切正常。这个实验证明,3559AV10原创 2019-02-20 15:54:21 · 6082 阅读 · 9 评论 -
使用SEQ2SEQ MODEL WITH THE HYBRID FRONTEND---pytorch scripting使用技巧
作者: Matthew Inkawhich 本教程将介绍使用PyTorch的Hybrid Frontend将序列到序列模型转换为Torch脚本的过程。我们将转换的模型是Chatbot教程中的chatbot模型 。您可以将本教程视为Chatbot教程的“第2部分”并部署您自己的预训练模型,或者您可以从本文档开始并使用我们托管的预训练模型。在后一种情况下,您可以参考原始的Chatbot教程,以获取...原创 2019-03-01 18:13:41 · 1159 阅读 · 0 评论 -
TX2 cuda runtime error (7) : too many resources requested for launch ,运行错误解决方法
RuntimeError: cuda runtime error (7) : too many resources requested for launch at /home/nvidia/Downloads/pytorch/aten/src/THCUNN/generic/SpatialUpSamplingBilinear.cu:66Full log:CUDA_ENABLED: True...原创 2019-02-25 19:12:21 · 7451 阅读 · 6 评论 -
pytorch JIT浅解析
概要 Torch Script中的核心数据结构是ScriptModule。 它是Torch的nn.Module的类似物,代表整个模型作为子模块树。 与普通模块一样,ScriptModule中的每个单独模块都可以包含子模块,参数和方法。 在nn.Modules中,方法是作为Python函数实现的,但在ScriptModules方法中通常实现为Torch Script函数,这是一个静态类型的Pyt...原创 2019-01-16 17:25:07 · 42185 阅读 · 3 评论 -
Pytorch JIT 使用经验总结
注意所有的torch.operator,需要传dim的。如torch.cat(tensors, dim=0, out=None) → Tensor传参数必要要注意,dim绝对不能=-1,因为使用Trace的时候,CPU虽然可能一切正常,但是使用GPU进行Trace的时候会报错。一般会报如下错误:torch.jit.TracingCheckError: Tracing failed san...原创 2019-01-26 18:42:59 · 8168 阅读 · 2 评论 -
pytorch--How to free CPU RAM after `module.to(cuda_device)`?
How to free CPU RAM after module.to(cuda_device)?大家在使用pytorch的时候,可能会发现一个问题,就是呢,我们使用module.to(cuda_device) 语句后,模型转到了gpu,显存增长了但是同样内存也增长了,一般不管网络多大,最少涨2G。我在lenet测试了,在maskrcnn-benchmark项目均测试过,效果都是这样子。这...原创 2019-01-17 16:51:24 · 1109 阅读 · 0 评论