Gluon-ts: Why does the PyTorchPredictor still need to import MXNet

Created on 30 Nov 2020  路  6Comments  路  Source: awslabs/gluon-ts

https://github.com/awslabs/gluon-ts/tree/master/src/gluonts/torch
This sub-package reimplements the Predictor method using Pytorch. I think the goal is to become irrelevant to the MXNet during the inference stage, and we can also use the Predictor API in a Pytorch-only environment.

However, when I trained a model and saved it. I use the PyTorchPredictor API as Predictor. But the runtime environment also needs to import the MXNet. I am wondering what is the significance of PyTorchPredictor.

bug question

All 6 comments

But the runtime environment also needs to import the MXNet.

@chendhui what do you mean by that? There's an example notebook using this class, which runs fine without having MXNet installed, if I remember correctly

Hey @chendhui, thanks for opening the issue.
Just checked, there is some dependency left:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-602532f91f38> in <module>
      1 from gluonts.dataset.field_names import FieldName
----> 2 from gluonts.dataset.loader import TrainDataLoader
      3 print(sys.modules.keys())
      4 print()
      5 print()

~/Projects/gts/gluon-ts/src/gluonts/dataset/loader.py in <module>
     26 from gluonts.dataset.util import MPWorkerInfo
     27 from gluonts.itertools import batcher, cyclic, pseudo_shuffled
---> 28 from gluonts.transform import Transformation, TransformedDataset
     29 
     30 logger = logging.getLogger(__name__)

~/Projects/gts/gluon-ts/src/gluonts/transform/__init__.py in <module>
     64 ]
     65 
---> 66 from ._base import (
     67     AdhocTransform,
     68     Chain,

~/Projects/gts/gluon-ts/src/gluonts/transform/_base.py in <module>
     17 
     18 # First-party imports
---> 19 from gluonts.core.component import validated
     20 from gluonts.dataset.common import DataEntry
     21 from gluonts.runtime_params import GLUONTS_MAX_IDLE_TRANSFORMS

~/Projects/gts/gluon-ts/src/gluonts/core/component.py in <module>
    178 
    179 
--> 180 @equals.register(mx.gluon.HybridBlock)
    181 def equals_representable_block(
    182     this: mx.gluon.HybridBlock, that: mx.gluon.HybridBlock

AttributeError: module 'mxnet' has no attribute 'gluon'

Right! I think I have a local branch where I had started reorganizing code and imports to get rid of these things. I'll try to rebase it, hopefully not much changed since then

@chendhui the desired goal, as you say, is to have the package independent of MXNet unless MXNet-based models are used -- however this is still in progress, so thanks for pointing that out 馃憤

@chendhui this should be fixed in the master branch now, please let me know if you keep seeing the issue

Thank you very much for your reply. Looking forward to the fixed codes.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AIAficionado picture AIAficionado  路  7Comments

jaheba picture jaheba  路  4Comments

alexcombessie picture alexcombessie  路  6Comments

MaximilianPavon picture MaximilianPavon  路  3Comments

Hari7696 picture Hari7696  路  9Comments