Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

模型剪枝后的速度问题 #70339

Closed
dsdsknfsk opened this issue Dec 19, 2024 · 7 comments
Closed

模型剪枝后的速度问题 #70339

dsdsknfsk opened this issue Dec 19, 2024 · 7 comments
Assignees
Labels
status/close 已关闭 type/question 用户提问

Comments

@dsdsknfsk
Copy link

dsdsknfsk commented Dec 19, 2024

请提出你的问题 Please ask your question

我们把torch的mmedetction框架上的一个目标检测模型(gfl)和它的剪枝模型(压缩约45%,结构性剪枝)都转成了paddle模型。(使用的是ppdetction框架,只用作推理)
具体的转换方法:
将torch上的模型权重和形状复制到paddle上
问题:
结构化剪枝后的模型与原模型的速度在GPU上测的结果没有提升,但是在CPU上测的结果有大幅提升(剪枝后的模型速度约为未剪枝的两倍),请问这是为什么?剪枝后模型需要额外的GPU设置才能加速吗
一些具体的指标如下
1734920022082(1)

@dsdsknfsk
Copy link
Author

dsdsknfsk commented Dec 19, 2024

剪枝前的部分参数shape如下:
backbone.conv1.conv1.conv.weight:[64, 3, 7, 7]
backbone.conv1.conv1.norm.weight:[64]
backbone.conv1.conv1.norm.bias:[64]
backbone.conv1.conv1.norm._mean:[64]
backbone.conv1.conv1.norm._variance:[64]
backbone.res2.res2a.branch2a.conv.weight:[64, 64, 1, 1]
backbone.res2.res2a.branch2a.norm.weight:[64]
backbone.res2.res2a.branch2a.norm.bias:[64]
backbone.res2.res2a.branch2a.norm._mean:[64]
backbone.res2.res2a.branch2a.norm._variance:[64]
与之对应的剪枝后的部分参数shape如下:
backbone.conv1.conv1.conv.weight:[56, 3, 7, 7]
backbone.conv1.conv1.norm.weight:[56]
backbone.conv1.conv1.norm.bias:[56]
backbone.conv1.conv1.norm._mean:[56]
backbone.conv1.conv1.norm._variance:[56]
backbone.res2.res2a.branch2a.conv.weight:[40, 56, 1, 1]
backbone.res2.res2a.branch2a.norm.weight:[40]
backbone.res2.res2a.branch2a.norm.bias:[40]
backbone.res2.res2a.branch2a.norm._mean:[40]
backbone.res2.res2a.branch2a.norm._variance:[40]

@FeixLiu
Copy link
Contributor

FeixLiu commented Dec 19, 2024

@zoooo0820 辛苦帮忙看下推理剪枝的问题

@dsdsknfsk
Copy link
Author

@zoooo0820 能否解答一下

@sealoongleft
Copy link

兄弟我也用了coco数据集,你哪个机构的,可以加个联系方式吗,以后有机会合作

@zoooo0820
Copy link
Contributor

@dsdsknfsk 您好,能否方便提供下转换前后的权重(如果真实权重不方便,随机初始化也可以的)和运行命令呢,我们复现下相关问题

@dsdsknfsk
Copy link
Author

@dsdsknfsk 您好,能否方便提供下转换前后的权重(如果真实权重不方便,随机初始化也可以的)和运行命令呢,我们复现下相关问题

感谢回复,ppdet内部的代码我们也做了一些修改,所以不太好直接提供复现,如果必要的话我后续再整理一下代码、模型权重以及运行命令

@zoooo0820
Copy link
Contributor

已线下沟通解决,如果有问题辛苦再reopen这个issue~

@paddle-bot paddle-bot bot added status/close 已关闭 and removed status/new-issue 新建 labels Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/close 已关闭 type/question 用户提问
Projects
None yet
Development

No branches or pull requests

4 participants