Gluon CV: impossible to load models into Sagemaker


#1

Hi,

I’ve followed the first tutorial on Gluon CV (https://gluon-cv.mxnet.io/build/examples_classification/demo_cifar10.html).

I’ve got an exception on the load model step:
Code:
net = get_model('cifar_resnet110_v1', classes=10, pretrained=True)
Error:
AssertionError: Parameter conv0_weight is missing in file /home/ec2-user/.mxnet/models/cifar_resnet110_v1-a0e1f860.params

I’ve tried all the other CIFAR models, there is always an Assertion Error.

Full stack:
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
in ()
----> 1 net = get_model(‘CIFAR_ResNet110_v1’, classes=10, pretrained=True)
2 #net = model_zoo.cifar_resnet110_v1(pretrained=True)

~/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/gluoncv/model_zoo/model_zoo.py in get_model(name, **kwargs)
    103     if name not in models:
    104         raise ValueError('%s\n\t%s' % (upstream_supported, '\n\t'.join(sorted(models.keys()))))
--> 105     net = models[name](**kwargs)
    106     return net

~/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/gluoncv/model_zoo/cifarresnet.py in cifar_resnet110_v1(**kwargs)
    317         Location for keeping the model parameters.
    318     """
--> 319     return get_cifar_resnet(1, 110, **kwargs)
    320 
    321 def cifar_resnet20_v2(**kwargs):

~/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/gluoncv/model_zoo/cifarresnet.py in get_cifar_resnet(version, num_layers, pretrained, ctx, root, **kwargs)
    271         from .model_store import get_model_file
    272         net.load_params(get_model_file('cifar_resnet%d_v%d'%(num_layers, version),
--> 273                                        root=root), ctx=ctx)
    274     return net
    275 

~/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/gluon/block.py in load_params(self, filename, ctx, allow_missing, ignore_extra)
    315         """
    316         self.collect_params().load(filename, ctx, allow_missing, ignore_extra,
--> 317                                    self.prefix)
    318 
    319     def register_child(self, block):

~/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/mxnet/gluon/parameter.py in load(self, filename, ctx, allow_missing, ignore_extra, restore_prefix)
    667             for name in self.keys():
    668                 assert name in arg_dict, \
--> 669                     "Parameter %s is missing in file %s"%(name[lprefix:], filename)
    670         for name in arg_dict:
    671             if name not in self._params:

AssertionError: Parameter conv0_weight is missing in file /home/ec2-user/.mxnet/models/cifar_resnet110_v1-a0e1f860.params

#2

Hi Virginie,

This is very likely due to a breaking change in version 1.2 of mxnet. See the following github issue link for details: https://github.com/apache/incubator-mxnet/issues/11091. The issue has been addressed and patched in version 1.2.1 so I would recommend upgrading to mxnet v1.2.1 https://github.com/apache/incubator-mxnet/releases/tag/1.2.1.rc0