Get runtime error while using squeezenet model
Download squeezenet model, write the python code to test this model, while running, got runtime error as below:
/usr/local/lib/python2.7/dist-packages/skimage/transform/warps.py:84: UserWarning: The default mode, 'constant', will be changed to 'reflect' in skimage 0.15.
warn("The default mode, 'constant', will be changed to 'reflect' in "
Traceback (most recent call last):
File "test.py", line 31, in
Attach the python code which bring the above issue.
from caffe2.python import workspace from caffe2.python.models import squeezenet as mynet import caffe2.python.tutorials.helpers as helpers
init_net = mynet.init_net predict_net = mynet.predict_net predict_net.name = "squeezenet_predict" workspace.RunNetOnce(init_net) workspace.CreateNet(predict_net) p = workspace.Predictor(init_net.SerializeToString(), predict_net.SerializeToString())
img = "https://upload.wikimedia.org/wikipedia/commons/thumb/7/7b/Orange-Whole-%26-Split.jpg/1200px-Orange-Whole-%26-Split.jpg" img = "https://upload.wikimedia.org/wikipedia/commons/a/ac/Pretzel.jpg" img = "https://cdn.pixabay.com/photo/2015/02/10/21/28/flower-631765_1280.jpg" mean = 128 input_size = 227
img = helpers.loadToNCHW(img, mean, input_size)
results = p.run([img]) response = helpers.parseResults(results) print response
caffe2 14d24fd926290bd25fb801e4c4d68a1949afeb82
Minimum working example:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import numpy
import caffe2.python.workspace
with open('init_net.pb', 'rb') as f:
init_net = f.read()
with open('predict_net.pb', 'rb') as f:
predict_net = f.read()
predictor = caffe2.python.workspace.Predictor(init_net, predict_net)
x = numpy.ones([1, 784], dtype=numpy.float32)
output = predictor.run([x])
In release, the script causes a segmentation fault. When Caffe2 was compiled with -DCMAKE_BUILD_TYPE=Debug, the output is as follows (note the 0 vs 0 whereas it says 1 vs 1 in the error message above):
christoph:/tmp$ python caffe2.issue-1173.mwe.py
WARNING:root:This caffe2 python run does not have GPU support. Will run in CPU only mode.
WARNING:root:Debug message: No module named caffe2_pybind11_state_gpu
Traceback (most recent call last):
File "caffe2.issue-1173.mwe.py", line 16, in <module>
output = predictor.run([x])
RuntimeError: [enforce fail at tensor.h:671] i < dims_.size(). 0 vs 0. Exceeding ndim limit Error from operator:
input: "data" input: "conv1_w" input: "conv1_b" output: "conv1" type: "Conv" arg { name: "stride" i: 2 } arg { name: "pad" i: 0 } arg { name: "kernel" i: 3 } device_option { } engine: ""
** while accessing input: data
Caffe2 debug configuration:
-- ******** Summary ********
-- General:
-- Git version : 14d24fd
-- System : Linux
-- C++ compiler : /usr/bin/c++
-- C++ compiler version : 5.4.0
-- Protobuf compiler : /home/christoph/anaconda2/bin/protoc
-- CXX flags : -D_GLIBCXX_USE_CXX11_ABI=0 -fopenmp -Wno-deprecated -std=c++11 -O2 -fPIC -Wno-narrowing
-- Build type : Debug
-- Compile definitions :
--
-- BUILD_BINARY : ON
-- BUILD_PYTHON : ON
-- Python version : 2.7.13
-- Python library : /home/christoph/anaconda2/lib/libpython2.7.so
-- BUILD_SHARED_LIBS : ON
-- BUILD_TEST : ON
-- USE_ATEN : OFF
-- USE_ASAN : OFF
-- USE_CUDA : OFF
-- USE_EIGEN_FOR_BLAS : 1
-- USE_FFMPEG : OFF
-- USE_GFLAGS : OFF
-- USE_GLOG : OFF
-- USE_GLOO : OFF
-- USE_LEVELDB : OFF
-- USE_LITE_PROTO : OFF
-- USE_LMDB : OFF
-- USE_METAL : OFF
-- USE_MKL :
-- USE_MOBILE_OPENGL : OFF
-- USE_MPI : OFF
-- USE_NCCL : OFF
-- USE_NERVANA_GPU : OFF
-- USE_NNPACK : OFF
-- USE_OBSERVERS : ON
-- USE_OPENCV : OFF
-- USE_OPENMP : ON
-- USE_REDIS : OFF
-- USE_ROCKSDB : OFF
-- USE_THREADS : ON
-- USE_ZMQ : OFF
I have the same problem, have you resolved it?
@yangqiongyongyu have you resolved?
have you resolved the problem? @johnzhou1 @yangqiongyongyu @wm10240
Not yet
@XiaoquinNUDT Not yet
It may be that the shape of your image is wrong, if you're using squeezenet model then try this as dummy input: fake_image = np.random.rand(1, 3, 227, 227).astype(np.float32) output = pred.run({"data": fake_image})
instead of: x = numpy.ones([1, 784], dtype=numpy.float32) output = predictor.run([x])