Segmentation fault when using 'simple_bind'
Hi, I've got a 'Segmentation fault' when I try to use a pre-trained model to do simple_bind operation. The model is converted from vgg16 Caffe model by the tool in mxnet. And the code works if I comment out the last line.
This is the code:
import numpy as np
import mxnet as mx
X=mx.io.ImageRecordIter(
path_imgrec ='data/'+"val_rec.bin",
mean_r =123.68,
mean_g =116.779,
mean_b =103.939,
rand_crop =False,
rand_mirror =False,
data_shape =(3,224,224),
batch_size =32,
num_parts =1,
part_index =0)
prefix='model/vgg16'
devs=mx.gpu()
vgg_model=mx.model.FeedForward.load(prefix,1,ctx=devs)
vgg_exec=vgg_model.symbol.simple_bind(vgg_model.ctx[0],grad_req='null',**dict(X.provide_data))
This is what I got from gdb

ping @winstywang
If you want to use FeedForward model you should use it's fit API instead of binding by yourself.
Thank you for your reply. Since I just want to do predicting instead of training, the fit API is not a choice here. And the source code in predict function in mxnet also use simple_bind like what I do above. And I've found that if I replace devs=mx.gpu() with devs=mx.cpu(), it works without segmentation fault.
@piiswrong To make it more clear, I think the code is the same as FeedForward._init_predictor since I just take the symbol out from the model and do simple_bind.
Can you run any example with GPU? a quick work around is to fit with end_epoch=0 so that FeedFoward model can bind for you without training
model = mx.model.FeedForward.load('path/to/model', 5, ctx=mx.gpu(0))
data = your_data_iter
depth = model.predict(data)
This code works fine for me.
@piiswrong He only needs the symbol stored in the checkpoint. If he initializes the symbol from scratch, it works fine.
https://github.com/dmlc/mxnet/issues/865