Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Segmentation fault when using 'simple_bind' #817

Closed
sodabeta7 opened this issue Dec 4, 2015 · 8 comments
Closed

Segmentation fault when using 'simple_bind' #817

sodabeta7 opened this issue Dec 4, 2015 · 8 comments

Comments

@sodabeta7
Copy link
Contributor

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

gdb

@sodabeta7
Copy link
Contributor Author

ping @winstywang

@piiswrong
Copy link
Contributor

If you want to use FeedForward model you should use it's fit API instead of binding by yourself.

@sodabeta7
Copy link
Contributor Author

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.

@sodabeta7
Copy link
Contributor Author

@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.

@piiswrong
Copy link
Contributor

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

@piiswrong
Copy link
Contributor

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.

@winstywang
Copy link
Contributor

@piiswrong He only needs the symbol stored in the checkpoint. If he initializes the symbol from scratch, it works fine.

@piiswrong
Copy link
Contributor

#865

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants