MMdnn icon indicating copy to clipboard operation
MMdnn copied to clipboard

ImportError: dynamic module does not define module export function (PyInit__caffe)

Open barkerje opened this issue 6 years ago • 3 comments

Platform: Ubuntu 16.04 (Azure Deep Learning VM)

Python version: Python 3.5.4 :: Anaconda

Source framework with version: Caffe 1.0.0

Destination framework with version: Keras 2.2.4 GPU

Pre-trained model path: https://github.com/lmb-freiburg/flownet2

Running scripts:

I cloned the flownet2 repo and ran the download-models.sh file in the "models" folder to get the model files. I then attempted to convert the model from caffe to keras using the following command:

mmconvert -sf caffe -in flownet2/models/FlowNet2-KITTI/FlowNet2-KITTI_deploy.prototxt.template -iw flownet2/models/FlowNet2-KITTI/FlowNet2-KITTI_weights.caffemodel.h5 -df keras -om flownet2_kitti.h5 --inputShape 80,80,3

However I get the following error:

jobarker@ImageVM:~$ mmconvert -sf caffe -in flownet2-master/models/FlowNet2-KITTI/FlowNet2-KITTI_deploy.prototxt.template -iw flownet2-master/models/FlowNet2-KITTI/FlowNet2-KITTI_weights.caffemodel.h5 -df keras -om flownet1_kitti.h5 --inputShape 80,80,3
Traceback (most recent call last):
  File "/anaconda/envs/py35/bin/mmconvert", line 11, in <module>
    sys.exit(_main())
  File "/anaconda/envs/py35/lib/python3.5/site-packages/mmdnn/conversion/_script/convert.py", line 102, in _main
    ret = convertToIR._convert(ir_args)
  File "/anaconda/envs/py35/lib/python3.5/site-packages/mmdnn/conversion/_script/convertToIR.py", line 16, in _convert
    transformer = CaffeTransformer(args.network, args.weights, "tensorflow", inputshape[0], phase = args.caffePhase)
  File "/anaconda/envs/py35/lib/python3.5/site-packages/mmdnn/conversion/caffe/transformer.py", line 309, in __init__
    model = get_caffe_resolver().NetParameter()
  File "/anaconda/envs/py35/lib/python3.5/site-packages/mmdnn/conversion/caffe/resolver.py", line 32, in get_caffe_resolver
    SHARED_CAFFE_RESOLVER = CaffeResolver()
  File "/anaconda/envs/py35/lib/python3.5/site-packages/mmdnn/conversion/caffe/resolver.py", line 8, in __init__
    self.import_caffe()
  File "/anaconda/envs/py35/lib/python3.5/site-packages/mmdnn/conversion/caffe/resolver.py", line 14, in import_caffe
    import caffe
  File "/opt/caffe/python/caffe/__init__.py", line 1, in <module>
    from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer
  File "/opt/caffe/python/caffe/pycaffe.py", line 13, in <module>
    from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
ImportError: dynamic module does not define module export function (PyInit__caffe)

Which seems to be related to this caffe error, but I am not sure how to solve it in the context of the mmdnn converter.

barkerje avatar Dec 03 '18 20:12 barkerje

You should use python 2.7 as python 3.x not support caffe

suikammd avatar Dec 16 '18 16:12 suikammd

Caffe should support Python 3.3+ http://caffe.berkeleyvision.org/installation.html

And here is solution to problem: https://github.com/BVLC/caffe/issues/6054

mrgloom avatar Feb 24 '19 16:02 mrgloom

python3.* is ok.

gmt710 avatar Jul 22 '20 10:07 gmt710