huawei-noah / Efficient-AI-Backbones

Efficient AI Backbones including GhostNet, TNT and MLP, developed by Huawei Noah's Ark Lab.
4.07k stars 708 forks source link

torch.hub ghostnet example is broken due to new cupy dependency #173

Open NicolasHug opened 1 year ago

NicolasHug commented 1 year ago

Hi all,

We're the maintainers of torch.hub and it looks like executing the code in the ghostnet example fails with the following error:

E             File "python_code/pytorch_vision_ghostnet.py", line 2, in <module>
E               model = torch.hub.load('huawei-noah/ghostnet', 'ghostnet_1x', pretrained=True)
E             File "/home/circleci/miniconda3/lib/python3.8/site-packages/torch/hub.py", line 543, in load
E               model = _load_local(repo_or_dir, model, *args, **kwargs)
E             File "/home/circleci/miniconda3/lib/python3.8/site-packages/torch/hub.py", line 570, in _load_local
E               hub_module = _import_module(MODULE_HUBCONF, hubconf_path)
E             File "/home/circleci/miniconda3/lib/python3.8/site-packages/torch/hub.py", line 88, in _import_module
E               spec.loader.exec_module(module)
E             File "<frozen importlib._bootstrap_external>", line 843, in exec_module
E             File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
E             File "/home/circleci/.cache/torch/hub/huawei-noah_ghostnet_master/hubconf.py", line 6, in <module>
E               from snnmlp_pytorch.models.snn_mlp import SNNMLP
E             File "/home/circleci/.cache/torch/hub/huawei-noah_ghostnet_master/snnmlp_pytorch/models/__init__.py", line 3, in <module>
E               from .snn_mlp import SNNMLP
E             File "/home/circleci/.cache/torch/hub/huawei-noah_ghostnet_master/snnmlp_pytorch/models/snn_mlp.py", line 8, in <module>
E               from .snn_cuda import LIFSpike
E             File "/home/circleci/.cache/torch/hub/huawei-noah_ghostnet_master/snnmlp_pytorch/models/snn_cuda.py", line 10, in <module>
E               import cupy
E           ModuleNotFoundError: No module named 'cupy'

You can find more details about the execution here.

Is cupy now a required dependency to run the ghostnet model? It seems that it wasn't before. I'd just like to make sure whether it's absolutely needed or not, as otherwise we'd need to include it in our CI as well (which we'd preferably not do).

Thanks!

iamhankai commented 1 year ago

'cupy' is a required dependency to run SNN-MLP model in huawei-noah/Efficient-AI-Backbones

NicolasHug commented 1 year ago

Thanks for your reply @iamhankai Could you clarify whether this cupy dependency was added only recently, or it's always been a requirement?

iamhankai commented 1 year ago

@Gaffey