Skip to content

Sudden problems about device  #6448

Closed

Description

@b860306

Search before asking

Question

It has been used normally for a long time, and today this problem suddenly appeared 。

Traceback (most recent call last):
File "C:\Users\Administrator/.cache\torch\hub\ultralytics_yolov5_master\hubconf.py", line 43, in _create
device = select_device(('0' if torch.cuda.is_available() else 'cpu') if device is None else device)
File "C:\Users\Administrator/.cache\torch\hub\ultralytics_yolov5_master\utils\torch_utils.py", line 74, in select_device
assert nd > int(max(device.split(','))), f'Invalid --device {device} request, valid devices are 0 - {nd - 1}'
AssertionError: Invalid --device 0 request, valid devices are 0 - -1

Additional

none

Activity

  1. github-actions commented on Jan 27, 2022

    @github-actions
    Contributor

    👋 Hello @b860306, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

    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 training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

    For business inquiries or professional support requests please visit https://ultralytics.com or email support@ultralytics.com.

    Requirements

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

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

    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 currently passing. CI tests verify correct operation of YOLOv5 training (train.py), validation (val.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

  2. RossLeeThomas commented on Jan 27, 2022

    @RossLeeThomas

    Same error my side. Also running on Windows.
    Been running for a few months, only stopped working on the latest pull. If I revert back to an older repo it works again.
    Seems to be related to the recent GPU selection fixes on Windows?

    Traceback (most recent call last):
    File "c:\Gitlab\yolov5\hubconf.py", line 43, in _create
    device = select_device(('0' if torch.cuda.is_available() else 'cpu') if device is None else device)
    File "c:\Gitlab\yolov5\utils\torch_utils.py", line 74, in select_device
    assert nd > int(max(device.split(','))), f'Invalid --device {device} request, valid devices are 0 - {nd - 1}'
    AssertionError: Invalid --device 0 request, valid devices are 0 - -1

  3. b860306 commented on Jan 27, 2022

    @b860306
    Author

    Same error my side. Also running on Windows. Been running for a few months, only stopped working on the latest pull. If I revert back to an older repo it works again. Seems to be related to the recent GPU selection fixes on Windows?

    Traceback (most recent call last): File "c:\Gitlab\yolov5\hubconf.py", line 43, in _create device = select_device(('0' if torch.cuda.is_available() else 'cpu') if device is None else device) File "c:\Gitlab\yolov5\utils\torch_utils.py", line 74, in select_device assert nd > int(max(device.split(','))), f'Invalid --device {device} request, valid devices are 0 - {nd - 1}' AssertionError: Invalid --device 0 request, valid devices are 0 - -1

    Sorry , can i ask you how to revert back to an older repo?

  4. RossLeeThomas commented on Jan 27, 2022

    @RossLeeThomas

    I changed to another branch on git updated 21 hours ago 'updates/benchmarks'.

  5. RossLeeThomas commented on Jan 27, 2022

    @RossLeeThomas

    Reverting this commit (856d4e5) also fixes the issue for me.

  6. b860306 commented on Jan 27, 2022

    @b860306
    Author

    Reverting this commit (856d4e5) also fixes the issue for me.

    I followed the steps (856d4e5)
    Both profiles( torch_utils.py / datasets.py ) were updated .

    But it's still the same problem

  7. RossLeeThomas commented on Jan 27, 2022

    @RossLeeThomas

    created a fork you can try download, same as master branch just with the last commit reverted. https://github.com/RossLeeThomas/yolov5.git

  8. b860306 commented on Jan 27, 2022

    @b860306
    Author

    創建了一個分支,您可以嘗試下載,與主分支相同,只是還原了最後一次提交。 https://github.com/RossLeeThomas/yolov5.git

    Oh ! it works again.
    You've saved my life.

  9. StevenLi-phoenix commented on Jan 27, 2022

    @StevenLi-phoenix

    Have the same issue with jetson

  10. glenn-jocher commented on Jan 28, 2022

    @glenn-jocher
    Member

    Sorry guys, it looks like a recent PR #6434 broke Windows GPU compatibility. I'll work on a fix ASAP.

  11. glenn-jocher commented on Jan 28, 2022

    @glenn-jocher
    Member

    In the meantime you can checkout the previous commit easily with this code:

    git clone https://github.com/ultralytics/yolov5
    cd yolov5
    git checkout fe7de6a82da3444d755453f86f40b508f3b99419
  12. StevenLi-phoenix commented on Jan 28, 2022

    @StevenLi-phoenix

    Sorry guys, it looks like a recent PR #6434 broke Windows GPU compatibility. I'll work on a fix ASAP.

    It does not work with jetson tx2 too.

    截屏2022-01-28 下午2 35 31

    without the option of device It works fine.
    But as soon as I select device 0. It became out of range.
    how can I select device between 0 and -1. It's impossible.

  13. linked a pull request that will close this issueFix2 `select_device()` for Multi-GPU #6461on Jan 28, 2022
  14. glenn-jocher commented on Jan 28, 2022

    @glenn-jocher
    Member

    @b860306 @RossLeeThomas @StevenLi-phoenix good news 😃! Your original issue may now be fixed ✅ in PR #6461. To receive this update:

    • Git – git pull from within your yolov5/ directory or git clone https://github.com/ultralytics/yolov5 again
    • PyTorch Hub – Force-reload model = torch.hub.load('ultralytics/yolov5', 'yolov5s', force_reload=True)
    • Notebooks – View updated notebooks Open In Colab Open In Kaggle
    • Docker – sudo docker pull ultralytics/yolov5:latest to update your image Docker Pulls

    Thank you for spotting this issue and informing us of the problem. Please let us know if this update resolves the issue for you, and feel free to inform us of any other issues you discover or feature requests that come to mind. Happy trainings with YOLOv5 🚀!

  15. RossLeeThomas commented on Jan 28, 2022

    @RossLeeThomas

    Working for me. Thanks @glenn-jocher

  16. glenn-jocher commented on Jan 28, 2022

    @glenn-jocher
    Member

    @RossLeeThomas great! Thanks for the feedback.

  17. Gowtham-369 commented on Apr 18, 2022

    @Gowtham-369

    Search before asking

    Question

    It has been used normally for a long time, and today this problem suddenly appeared 。

    Traceback (most recent call last): File "C:\Users\Administrator/.cache\torch\hub\ultralytics_yolov5_master\hubconf.py", line 43, in _create device = select_device(('0' if torch.cuda.is_available() else 'cpu') if device is None else device) File "C:\Users\Administrator/.cache\torch\hub\ultralytics_yolov5_master\utils\torch_utils.py", line 74, in select_device assert nd > int(max(device.split(','))), f'Invalid --device {device} request, valid devices are 0 - {nd - 1}' AssertionError: Invalid --device 0 request, valid devices are 0 - -1

    Additional

    none

    Same error I faced today while hosting using flask. Tried all the available suggestions but no solution found
    Traceback (most recent call last): File "/home/ugrdsa/.cache/torch/hub/ultralytics_yolov5_master/hubconf.py", line 43, in _create device = select_device(('0' if torch.cuda.is_available() else 'cpu') if device is None else device) File "/home/ugrdsa/.cache/torch/hub/ultralytics_yolov5_master/utils/torch_utils.py", line 79, in select_device LOGGER.info(s.encode().decode('ascii', 'ignore') if platform.system() == 'Windows' else s) # emoji-safe File "/usr/lib/python3.8/logging/__init__.py", line 1434, in info self._log(INFO, msg, args, **kwargs) File "/usr/lib/python3.8/logging/__init__.py", line 1577, in _log self.handle(record) File "/usr/lib/python3.8/logging/__init__.py", line 1587, in handle self.callHandlers(record) File "/usr/lib/python3.8/logging/__init__.py", line 1649, in callHandlers hdlr.handle(record) File "/usr/lib/python3.8/logging/__init__.py", line 950, in handle self.emit(record) File "/usr/lib/python3.8/logging/__init__.py", line 1084, in emit stream.write(msg + self.terminator)

  18. glenn-jocher commented on Apr 19, 2022

    @glenn-jocher
    Member

    @Gowtham-369 👋 hi, thanks for letting us know about this possible problem with YOLOv5 🚀. We've created a few short guidelines below to help users provide what we need in order to start investigating a possible problem.

    How to create a Minimal, Reproducible Example

    When asking a question, people will be better able to provide help if you provide code that they can easily understand and use to reproduce the problem. This is referred to by community members as creating a minimum reproducible example. Your code that reproduces the problem should be:

    • ✅ Minimal – Use as little code as possible to produce the problem
    • ✅ Complete – Provide all parts someone else needs to reproduce the problem
    • ✅ Reproducible – Test the code you're about to provide to make sure it reproduces the problem

    For Ultralytics to provide assistance your code should also be:

    • ✅ Current – Verify that your code is up-to-date with GitHub master, and if necessary git pull or git clone a new copy to ensure your problem has not already been solved in master.
    • ✅ Unmodified – Your problem must be reproducible using official YOLOv5 code without changes. Ultralytics does not provide support for custom code ⚠️.

    If you believe your problem meets all the above criteria, please close this issue and raise a new one using the 🐛 Bug Report template with a minimum reproducible example to help us better understand and diagnose your problem.

    Thank you! 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions