How to Fix “AssertionError: CUDA unavailable, invalid device 0 requested”

We Are Going To Discuss About How to Fix “AssertionError: CUDA unavailable, invalid device 0 requested”. So lets Start this Python Article.

How to Fix “AssertionError: CUDA unavailable, invalid device 0 requested”

  1. How to solve How to Fix “AssertionError: CUDA unavailable, invalid device 0 requested”

    You forgot to put the == signs between the packages and the version number. According to the PyTorch installation page:
    py -m pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio===0.9.0 -f https://download.pytorch.org/whl/torch_stable.html

  2. How to Fix “AssertionError: CUDA unavailable, invalid device 0 requested”

    You forgot to put the == signs between the packages and the version number. According to the PyTorch installation page:
    py -m pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio===0.9.0 -f https://download.pytorch.org/whl/torch_stable.html

Solution 1

You forgot to put the == signs between the packages and the version number. According to the PyTorch installation page:

py -m pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio===0.9.0 -f https://download.pytorch.org/whl/torch_stable.html

Original Author Ivan Of This Content

Solution 2

Ok after 1 week of pain I have founded this solution

1- After download NVIDIA Driver:

  • Go to your window and search for “NVIDIA Control Panel”
  • Then at the bottom left there should be “System Information”
  • Then look for “CUDA Cores”
  • Mine is 384 (year my laptop is antique) (NVIDIA GeForce GT 750M)
  • For CUDA Cores: 384 (corresponds to CUDA Toolkit 9.0)
  • For CUDA Cores: 387 (corresponds to CUDA Toolkit 9.1)
  • For other CUDA Cores you will need to do some more research yourself because I’m honestly don’t know where to find this (if you are curious about where I found the one above, its on the second comments “https://github.com/pytorch/pytorch/issues/4546”

2- (Optional) Download Anaconda

  • This is the system I use, the choice is your
  • If you are using Anaconda and have been installing and uninstall to
    fix this problem. I recommend you to clean uninstall the environment
    since in my case my file got crash because of repeated install and
    un-install
  • Here is the link to show you how to do it
    “https://www.youtube.com/watch?v=dcvdOuvWI-Q&t=107s”

3- After install the right CUDA toolkit for your system

  • Go to “https://pytorch.org”
  • Put in your system details and install the right PyTorch for your
    system
  • (Optional) if you use Tensorflow as well, go here and install the
    right version for your CUDA

4- After all of that, in your Anaconda environment (or any environment you are using), type:

  • import torch
  • print(torch.cuda.is_available())

if return True then good job

if not: good luck on your coming week

hope it help and good luck on your journey with yolor (I’m learning it too)

Original Author James Ngo Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

ittutorial team

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment