How to add a new model ? #278
-
Hi, I tried adding a new model to no avail.
@register_model_func
def smpnetv1_05m_m1(pretrained_cfg: str = 'smpnetv1_05m_m1', pretrained: bool = False, **kwargs: Any) -> SimpleNet:
model_args = dict(**kwargs)
return _create_simpnet(1000, scale=0.5, network_idx=17, mode=1, pretrained=pretrained) and saved everything. ImportError: cannot import name 'register_model_func_func' from 'torchdistill.models.registry' (/home/hossein/torchdistill/torchdistill/models/registry.py) here is the full error message (I was trying to load an existing example before working with the new model, but nevertheless, the error pops up regardless) (base) hossein@hossein-pc:~/torchdistill$ python -m torch.distributed.launch --nproc_per_node=1 --use_env examples/image_classification.py --world_size 1 --config configs/sample/ilsvrc2012/single_stage/kd/alexnet_from_resnet152.yaml --log log/ilsvrc2012/kd/alexnet_from_resnet152.txt
/home/hossein/anaconda3/lib/python3.9/site-packages/torch/distributed/launch.py:178: FutureWarning: The module torch.distributed.launch is deprecated
and will be removed in future. Use torchrun.
Note that --use_env is set by default in torchrun.
If your script expects `--local_rank` argument to be set, please
change it to read from `os.environ['LOCAL_RANK']` instead. See
https://pytorch.org/docs/stable/distributed.html#launch-utility for
further instructions
warnings.warn(
Traceback (most recent call last):
File "/home/hossein/torchdistill/examples/image_classification.py", line 15, in <module>
from torchdistill.core.distillation import get_distillation_box
File "/home/hossein/torchdistill/torchdistill/core/__init__.py", line 1, in <module>
from . import pre_epoch_proc, pre_forward_proc, forward_proc, post_forward_proc, post_epoch_proc
File "/home/hossein/torchdistill/torchdistill/core/post_epoch_proc.py", line 6, in <module>
from ..models.wrapper import AuxiliaryModelWrapper
File "/home/hossein/torchdistill/torchdistill/models/__init__.py", line 2, in <module>
from .classification import CLASSIFICATION_MODEL_FUNC_DICT
File "/home/hossein/torchdistill/torchdistill/models/classification/__init__.py", line 1, in <module>
from . import densenet, resnet, wide_resnet,simplenet
File "/home/hossein/torchdistill/torchdistill/models/classification/simplenet.py", line 10, in <module>
from ..registry import register_model_func_func
ImportError: cannot import name 'register_model_func_func' from 'torchdistill.models.registry' (/home/hossein/torchdistill/torchdistill/models/registry.py)
ERROR:torch.distributed.elastic.multiprocessing.api:failed (exitcode: 1) local_rank: 0 (pid: 372873) of binary: /home/hossein/anaconda3/bin/python
Traceback (most recent call last):
File "/home/hossein/anaconda3/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/home/hossein/anaconda3/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/hossein/anaconda3/lib/python3.9/site-packages/torch/distributed/launch.py", line 193, in <module>
main()
File "/home/hossein/anaconda3/lib/python3.9/site-packages/torch/distributed/launch.py", line 189, in main
launch(args)
File "/home/hossein/anaconda3/lib/python3.9/site-packages/torch/distributed/launch.py", line 174, in launch
run(args)
File "/home/hossein/anaconda3/lib/python3.9/site-packages/torch/distributed/run.py", line 715, in run
elastic_launch(
File "/home/hossein/anaconda3/lib/python3.9/site-packages/torch/distributed/launcher/api.py", line 131, in __call__
return launch_agent(self._config, self._entrypoint, list(args))
File "/home/hossein/anaconda3/lib/python3.9/site-packages/torch/distributed/launcher/api.py", line 245, in launch_agent
raise ChildFailedError(
torch.distributed.elastic.multiprocessing.errors.ChildFailedError:
============================================================
examples/image_classification.py FAILED
------------------------------------------------------------
Failures:
<NO_OTHER_FAILURES>
------------------------------------------------------------
Root Cause (first observed failure):
[0]:
time : 2023-01-16_19:28:07
host : hossein-pc
rank : 0 (local_rank: 0)
exitcode : 1 (pid: 372873)
error_file: <N/A>
traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html
============================================================ How should I go about this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @Coderx7 , It seems you edited files under
from torchdistill.models.registry import register_model_func
# Some import statements here to call _create_simpnet
@register_model_func
def smpnetv1_05m_m1(pretrained_cfg: str = 'smpnetv1_05m_m1', pretrained: bool = False, **kwargs: Any) -> SimpleNet:
model_args = dict(**kwargs)
return _create_simpnet(1000, scale=0.5, network_idx=17, mode=1, pretrained=pretrained)
import my_module
|
Beta Was this translation helpful? Give feedback.
Hi @Coderx7 ,
It seems you edited files under
torchdistill/
in this repo. Note that torchdistill is available as a PyPI package and installable (pip install torchdistill
), and I'm currently working on next release and editing files undertorchdistill/
.For this reason, I suggest you do not edit
torchdistill/
to add new modules, but instead it is designed to add new modules by registry function like you did (almost there, but you editedtorchdistill/
files)pip uninstall torchdistill
if you installed the localtorchdistill
instead of one available at PyPIpip install torchdistill
examples/
(sayexa…