I'm creating this issue based on conversation from a keras-mxnet user on changes in latest keras-mxnet:
Setting the context (number of GPUs or CPU) has changed due to the underlying changes in MXNet-1.5.x and this breaks for us.
If the context is provided in model.compile(), it is still using the older method, and fails:
https://github.com/awslabs/keras-apache-mxnet/blob/master/keras/backend/mxnet_backend.py#L5404
Related to context, there are a few other issues that are problematic:
Traceback (most recent call last):
File "examples/cifar10_resnet.py", line 338, in <module>
metrics=['accuracy'], context="gpu(0)")
File "/usr/local/lib/python2.7/dist-packages/keras/backend/mxnet_backend.py", line 5404, in compile
self._context = self.get_mxnet_context(kwargs['context'])
AttributeError: 'Model' object has no attribute 'get_mxnet_context'
Test case 2: pass context during model initialization
Traceback (most recent call last):
File "examples/mnist_mlp.py", line 36, in <module>
model = Sequential(context="gpu(1)")
File "/usr/local/lib/python2.7/dist-packages/keras/backend/mxnet_backend.py", line 5745, in __init__
engine.Model.__init__(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/keras/backend/mxnet_backend.py", line 5348, in __init__
super(Model, self).__init__(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/keras/legacy/interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/network.py", line 96, in __init__
self._init_subclassed_network(**kwargs)
TypeError: _init_subclassed_network() got an unexpected keyword argument 'context'
Test case 3: change context using model.set_mxnet_context
I'm creating this issue based on conversation from a keras-mxnet user on changes in latest keras-mxnet:
Here are the reproducible steps.
Using examples/mnist_mlp.py
Test case 1: pass context during compile
Change line45 to the following:
error
Test case 2: pass context during model initialization
Change line 36 to
error
Test case 3: change context using model.set_mxnet_context
add a line before model.compile
error