Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: Can't get attribute 'SiLU' on <module 'torch.nn.modules.activation' #1849

Closed
WANGCHAO1996 opened this issue Jan 6, 2021 · 6 comments · Fixed by #1853
Closed
Labels
question Further information is requested

Comments

@WANGCHAO1996
Copy link

❔Question

Using torch 1.6.0 CUDA:0 (GeForce RTX 2080 Ti, 11264.0MB)

Namespace(adam=False, batch_size=4, bucket='', cache_images=False, cfg='models/yolov5x.yaml', data='data/data.yaml', device='0', epochs=500, evolve=False, exist_ok=False, global_rank=-1, hyp='data/hyp.scratch.yaml', image_weights=False, img_size=[640, 640], local_rank=-1, log_artifacts=False, log_imgs=16, multi_scale=False, name='exp', noautoanchor=False, nosave=False, notest=False, project='runs/train', rect=False, resume=False, save_dir='runs\train\exp6', single_cls=False, sync_bn=False, total_batch_size=4, weights='weights/yolov5x.pt', workers=8, world_size=1)
Start Tensorboard with "tensorboard --logdir runs/train", view at http://localhost:6006/
Hyperparameters {'lr0': 0.01, 'lrf': 0.2, 'momentum': 0.937, 'weight_decay': 0.0005, 'warmup_epochs': 3.0, 'warmup_momentum': 0.8, 'warmup_bias_lr': 0.1, 'box': 0.05, 'cls': 0.5, 'cls_pw': 1.0, 'obj': 1.0, 'obj_pw': 1.0, 'iou_t': 0.2, 'anchor_t': 4.0, 'fl_gamma': 0.0, 'hsv_h': 0.015, 'hsv_s': 0.7, 'hsv_v': 0.4, 'degrees': 0.0, 'translate': 0.1, 'scale': 0.5, 'shear': 0.0, 'perspective': 0.0, 'flipud': 0.0, 'fliplr': 0.5, 'mosaic': 1.0, 'mixup': 0.0}
Traceback (most recent call last):
File "E:/yolov5-master/train.py", line 513, in
train(hyp, opt, device, tb_writer, wandb)
File "E:/yolov5-master/train.py", line 83, in train
ckpt = torch.load(weights, map_location=device) # load checkpoint
File "D:\d\Anaconda3\envs\yolov5\lib\site-packages\torch\serialization.py", line 584, in load
return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
File "D:\d\Anaconda3\envs\yolov5\lib\site-packages\torch\serialization.py", line 842, in _load
result = unpickler.load()
AttributeError: Can't get attribute 'SiLU' on <module 'torch.nn.modules.activation' from 'D:\d\Anaconda3\envs\yolov5\lib\site-packages\torch\nn\modules\activation.py'>
Internal process exited

Additional context

@WANGCHAO1996 WANGCHAO1996 added the question Further information is requested label Jan 6, 2021
@NanoCode012
Copy link
Contributor

Update torch to 1.7

@glenn-jocher glenn-jocher linked a pull request Jan 6, 2021 that will close this issue
@glenn-jocher glenn-jocher changed the title train error AttributeError: Can't get attribute 'SiLU' on <module 'torch.nn.modules.activation' Jan 6, 2021
@glenn-jocher
Copy link
Member

glenn-jocher commented Jan 6, 2021

@NanoCode012 I've created a PR #1853 that runs dependency checks before anything else. So far I've only added this to train.py, not detect.py or test.py, though perhaps I should add the checks there also in the if __name__ == '__main__': section.

I'm not sure how this will respond to conda packages, or if this would affect pytorch hub functionality, but it might help better identify these issues by providing clearer error messages. PyCharm does this already automatically which is nice (yellow bar in my screenshot), this would take it a step further and throw an error and prevent running of the code.

Screen Shot 2021-01-05 at 11 48 55 PM

EDIT: Original idea from https://stackoverflow.com/questions/16294819/check-if-my-python-has-all-required-packages

@NanoCode012
Copy link
Contributor

I ran a quick python train.py --epochs 3 on my conda env and got the error when running as expected when I was missing a package.

I'm using VS Code and don't see the same yellow bar as yours, but I think the error message does it well enough.

It might be good to add it to test/detect just to be on the safe side.

@glenn-jocher
Copy link
Member

@NanoCode012 ok great thanks for the feedback. I'll add add it to test and detect also.

@HamdiTarek
Copy link

How can I add 'SiLU' if my server doesn't support pip and the network is blocked (can't download anything)? my torch is 1.6.0. I can use only torch 1.6.0 on this server.

@glenn-jocher
Copy link
Member

@HamdiTarek

Requirements

Python>=3.6.0 with all requirements.txt installed including PyTorch>=1.7. To get started:

$ git clone https://github.com/ultralytics/yolov5
$ cd yolov5
$ pip install -r requirements.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants