Yolov5: Hardswish object has no attribute inplace

Created on 3 Nov 2020  路  7Comments  路  Source: ultralytics/yolov5

Dear all,

I am suffering a problem, when I used the 'detect.py' to predict one image, there is an error which is shown below:

"torch.nn.modules.module.ModuleAttributeError: 'Hardswish' object has no attribute 'inplace'"

current envs: pytorch:1.7.0, torchvision:0.8.1

could anyone can give me some suggestion? many thanks.

by the way, do I need to downgrade the pytorch version to 1.6.0 and torchvision to 0.7.0?

Regards

Most helpful comment

@glenn-jocher @guimaraesmarcelo,

First of all, thanks for your help.

To @glenn-jocher

By the way, that is an amazing project and you code is so beautiful.

I solved the problem when I downgrade my pytorch version(pytorch ver: 1.6.0 & torchvision is 0.7.0), it will be fine.

Regards

All 7 comments

Hello @enoceanwei, thank you for your interest in our work! Please visit our Custom Training Tutorial to get started, and see our Jupyter Notebook Open In Colab, Docker Image, and Google Cloud Quickstart Guide for example environments.

If this is a bug report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom model or data training question, please note Ultralytics does not provide free personal support. As a leader in vision ML and AI, we do offer professional consulting, from simple expert advice up to delivery of fully customized, end-to-end production solutions for our clients, such as:

  • Cloud-based AI systems operating on hundreds of HD video streams in realtime.
  • Edge AI integrated into custom iOS and Android apps for realtime 30 FPS video inference.
  • Custom data training, hyperparameter evolution, and model exportation to any destination.

For more information please visit https://www.ultralytics.com.

It appears you may have environment problems. Please ensure you meet all dependency requirements if you are attempting to run YOLOv5 locally. If in doubt, create a new virtual Python 3.8 environment, clone the latest repo (code changes daily), and pip install -r requirements.txt again. We also highly recommend using one of our verified environments below.

Requirements

Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.6. To install run:

$ pip install -r requirements.txt

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are passing. These tests evaluate proper operation of basic YOLOv5 functionality, including training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu.

@glenn-jocher @enoceanwei
It seems that this might be related to the requirements file. When using pytorch version 1.7.0 and torchvision version 0.8.1 it caused this error. I got it solved by downgrading pytorch to version 1.6.0 and torchvision 0.7.0.

Maybe the requirements file should restrict the torchvision version to version 0.7.0.

@guimaraesmarcelo that's odd. The CI tests run on torch 1.7.0 torchvision 0.8.1 cpu environments with no problem. You can see this here under Install Dependencies section of these tests. They run automatically every 24 hours on all 3 OS's:
https://github.com/ultralytics/yolov5/runs/1366325532?check_suite_focus=true

Screenshot 2020-11-07 at 23 50 16

@glenn-jocher @guimaraesmarcelo,

First of all, thanks for your help.

To @glenn-jocher

By the way, that is an amazing project and you code is so beautiful.

I solved the problem when I downgrade my pytorch version(pytorch ver: 1.6.0 & torchvision is 0.7.0), it will be fine.

Regards

I also have this issue and downgrading to 1.6 didn't help

Edit: I don't know how, but it works fine in pycharm or when I run it through the command line.

@JustinMBrown please note that most technical problems are due to:

  • Your modified or out-of-date code. If your issue is not reproducible in a new git clone version of this repo we can not debug it. Before going further run this code and verify your issue persists:
$ git clone https://github.com/ultralytics/yolov5 yolov5_new  # clone latest
$ cd yolov5_new
$ python detect.py  # verify detection

# CODE TO REPRODUCE YOUR ISSUE HERE
  • Your custom data. If your issue is not reproducible in one of our 3 common datasets (COCO, COCO128, or VOC) we can not debug it. Visit our Custom Training Tutorial for guidelines on training your custom data. Examine train_batch0.jpg and test_batch0.jpg for a sanity check of your labels and images.

  • Your environment. If your issue is not reproducible in one of the verified environments below we can not debug it. If you are running YOLOv5 locally, verify your environment meets all of the requirements.txt dependencies specified below. If in doubt, download Python 3.8.0 from https://www.python.org/, create a new venv, and then install requirements.

If none of these apply to you, we suggest you close this issue and raise a new one using the Bug Report template, providing screenshots and minimum viable code to reproduce your issue. Thank you!

Requirements

Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.6. To install run:

$ pip install -r requirements.txt

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are passing. These tests evaluate proper operation of basic YOLOv5 functionality, including training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Single430 picture Single430  路  4Comments

DucTaiVu picture DucTaiVu  路  3Comments

FSNStefan picture FSNStefan  路  4Comments

Alex-afka picture Alex-afka  路  3Comments

jaqub-manuel picture jaqub-manuel  路  4Comments