Have you tried to convert resnet50? I failed.
Flames60 opened this issue · 2 comments
The test.py has been ran correctly.
I used pytorch 0.4.0 to convert the pretrained resnet50 to onnx, but when I tried to convert it to the caffe model with this tool, I failed and I am not happy.
`I030818:14:05.266976 24239 layer_factory.hpp:77] Creating layer 0
I0308 18:14:05.267001 24239 net.cpp:100] Creating Layer 0
I0308 18:14:05.267019 24239 net.cpp:408] 0 -> 0
I0308 18:14:05.267062 24239 net.cpp:150] Setting up 0
I0308 18:14:05.267076 24239 net.cpp:157] Top shape: 10 3 224 224 (1505280)
I0308 18:14:05.267081 24239 net.cpp:165] Memory required for data: 6021120
I0308 18:14:05.267096 24239 layer_factory.hpp:77] Creating layer 268
I0308 18:14:05.267110 24239 net.cpp:100] Creating Layer 268
I0308 18:14:05.267117 24239 net.cpp:434] 268 <- 0
I0308 18:14:05.267127 24239 net.cpp:408] 268 -> 268
F0308 18:14:05.395298 24239 cudnn.hpp:113] Check failed: status == CUDNN_STATUS_SUCCESS (3 vs. 0) CUDNN_STATUS_BAD_PARAM
*** Check failure stack trace: ***
Aborted`
Hi, this is caused by the difference of pooling between caffe and pytorch. Caffe's pooling use "ceil" mode while pytorch's use "floor" mode by default. When the output shapes are not integers, they behaves different. For example, the output of Pooling(2, 2)(1, 3, 129, 129) will be (1, 3, 65, 65) in caffe and (1, 3, 64, 64) in pytorch. Unfortunately, there are several such kind of pooling in pytorch's offical resnet model. You need to set ceil_mode=True in pytorch when converting this kind of pooling to caffe. Check #3 for detail.
Hi, this is caused by the difference of pooling between caffe and pytorch. Caffe's pooling use "ceil" mode while pytorch's use "floor" mode by default. When the output shapes are not integers, they behaves different. For example, the output of Pooling(2, 2)(1, 3, 129, 129) will be (1, 3, 65, 65) in caffe and (1, 3, 64, 64) in pytorch. Unfortunately, there are several such kind of pooling in pytorch's offical resnet model. You need to set ceil_mode=True in pytorch when converting this kind of pooling to caffe. Check #3 for detail.
Thanks for your reply! I fixed it by add 'engine = CAFFE' in conv_param, but there is another error says that
ValueError: could not broadcast input array from shape (1000,2048) into shape (1000,8192)
Maybe it is caused by what you point out, I am trying to solve it.
Thanks a lot!