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

[Bug]: Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check #9970

Open
1 task done
Evil-Dragon opened this issue May 1, 2023 · 16 comments
Labels
asking-for-help-with-local-system-issues This issue is asking for help related to local system; please offer assistance

Comments

@Evil-Dragon
Copy link

Is there an existing issue for this?

  • I have searched the existing issues and checked the recent builds/commits

What happened?

New update of A111 with Torch 2.0 results in the following error on startup:

venv "G:\stable-diffusion-webui\venv\Scripts\Python.exe"
Python 3.10.9 (tags/v3.10.9:1dd9be6, Dec 6 2022, 20:01:21) [MSC v.1934 64 bit (AMD64)]
Commit hash: 72cd27a
Traceback (most recent call last):
File "G:\stable-diffusion-webui\launch.py", line 352, in
prepare_environment()
File "G:\stable-diffusion-webui\launch.py", line 257, in prepare_environment
run_python("import torch; assert torch.cuda.is_available(), 'Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check'")
File "G:\stable-diffusion-webui\launch.py", line 120, in run_python
return run(f'"{python}" -c "{code}"', desc, errdesc)
File "G:\stable-diffusion-webui\launch.py", line 96, in run
raise RuntimeError(message)
RuntimeError: Error running command.
Command: "G:\stable-diffusion-webui\venv\Scripts\python.exe" -c "import torch; assert torch.cuda.is_available(), 'Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check'"
Error code: 1
stdout:
stderr: Traceback (most recent call last):
File "", line 1, in
AssertionError: Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check

Press any key to continue . . .

I've tried a clean install by deleting venv and letting everything reinstall from scratch to no avail.

Steps to reproduce the problem

  1. Start batch file
  2. Press ....
  3. ...

What should have happened?

Normal startup, using --skip-torch-cuda-test results in xformers failing due to the lack of torch with cuda support.

Commit where the problem happens

72cd27a

What platforms do you use to access the UI ?

Windows

What browsers do you use to access the UI ?

Mozilla Firefox

Command Line Arguments

--xformers--no-half-vae --api --port 7050

List of extensions

Unrelated

Console logs

See above

Additional information

No response

@Evil-Dragon Evil-Dragon added the bug-report Report of a bug, yet to be confirmed label May 1, 2023
@Xalaxis
Copy link

Xalaxis commented May 1, 2023

This might be the same issue as described in this comment: #1742 (comment)

@Xalaxis
Copy link

Xalaxis commented May 1, 2023

Found it, it looks like download.pytorch.org's DNS is not resolving on some resolvers right now, specifically Cloudflare's 1.1.1.1, which causes pip to ignore the CUDA-specific download URL and fall back to the CPU one. After switching to Google's 8.8.8.8, flushing my DNS cache and deleting all the torch packages from the venv everything worked again.

Hopefully this issue will go away when whoever is in charge of their DNS fixes it, but if you have already downloaded the CPU version due to this bug you will need to manually delete the incorrect files.

One way to check if this is your problem is to try going to https://download.pytorch.org/whl/cu118 in your browser. If it works you have a different issue. If it's ERR_NAME_NOT_RESOLVED or similar you have this one.

@MellowCo
Copy link

MellowCo commented May 2, 2023

amd gpu? I think you installed cuda, but amd requires rocm.

You can run webui.sh, It will automatically install the required rocm for amd

if echo "$gpu_info" | grep -q "AMD" && [[ -z "${TORCH_COMMAND}" ]]
then
# AMD users will still use torch 1.13 because 2.0 does not seem to work.
export TORCH_COMMAND="pip install torch==1.13.1+rocm5.2 torchvision==0.14.1+rocm5.2 --index-url https://download.pytorch.org/whl/rocm5.2"
fi

or run pip install torch==1.13.1+rocm5.2 torchvision==0.14.1+rocm5.2 --index-url https://download.pytorch.org/whl/rocm5.2 reinstall

@timothe
Copy link

timothe commented May 2, 2023

I can confirm the pytorch.org link being unreacheable seems to be the issue. However I have switched from Cloudflare to Google and I still have the same issue. Waiting for an update on this.

@lebakerino
Copy link

lebakerino commented May 2, 2023

Same issue, spent all day messing about, I tried manually installing torch like described in [url]this(https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/1742#issuecomment-1429476506[/url]post with no luck.

Tried creating a new SD install and same issues.

Keep getting the errors

How does one change the DNS to be able to connect to the site to download? the links work intermittently for me, like if i delete my env eventually it connects in command prompt but the error still persists.

(Full description of my issue here but yeah, it's the same problem I completely overlooked the issues page and mistakenly posted in this discussions: #10016)

@timothe
Copy link

timothe commented May 22, 2023

Following the exact same process, with Google DNS, worked for me (yay!). I had changed the DNS before and it didn't work.
If it didn't work before for you, give it another shot. It seems there was some issues on their website before, indeed.

@Xalaxis
Copy link

Xalaxis commented May 24, 2023

How does one change the DNS to be able to connect to the site to download? the links work intermittently for me, like if i delete my env eventually it connects in command prompt but the error still persists.

If you see a message along the lines of "WARNING: Retrying" ..., multiple tries and then it eventually works, I believe it actually is failing to connect and falling back to the incorrect version of the library. If it's using the correct version there should be no "Retrying" messages.

Look for how to change your Operating System DNS to switch DNS provider.

@moxSedai
Copy link

Same issue but I can access https://download.pytorch.org/whl/cu118. Running on PopOS with a 3080, and cuda and pytorch work in the project I'm working on in PyCharm.

@dcarrawa
Copy link

The problem for me was that it was detecting the iGPU on my laptop as the primary GPU and installing the ROCm (AMD) version :

Installing torch and torchvision
Looking in indexes: https://download.pytorch.org/whl/rocm5.4.2
Collecting torch==2.0.1+rocm5.4.2
  Using cached https://download.pytorch.org/whl/rocm5.4.2/torch-2.0.1%2Brocm5.4.2-cp311-cp311-linux_x86_64.whl (1536.4 MB)

The fix was to remove the following lines from webui.sh

if echo "$gpu_info" | grep -q "AMD" && [[ -z "${TORCH_COMMAND}" ]]
then
    export TORCH_COMMAND="pip install torch==2.0.1+rocm5.4.2 torchvision==0.15.2+rocm5.4.2 --index-url https://download.pytorch.org/whl/rocm5.4.2"
fi

@tonyj2
Copy link

tonyj2 commented Jul 14, 2023

This` issue have a perfect solution!!!,and i will show you how did I sovle it !!! Step 1)update your NVIDIA driver,and then confirm which series pack of CUDA do your driver capable,pic in there !!!Step 2)update your NVIDIA cuda with correct package.https://developer.nvidia.com/cuda-toolkit-archive !!!Step 3)choose the right torch from web https://pytorch.org/get-started/previous-versions/ !!! Step 4) torch.cuda.is_available() #check it

@Vinicius-ufsc
Copy link

Vinicius-ufsc commented Jul 18, 2023

Error: RuntimeError: Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check

The solution for me was:

1- Download Geforce Experience
2- Download and update drivers using Geforce Experience app
3- run webui-user.bat again (no changes)


os: Windows 11, gpu: RTX 3060 12GB, drivers: 536.67

@Cyanex1702
Copy link

Cyanex1702 commented Jul 31, 2023

Let me simplify it:

I faced this issue to when I started but now I know how to handle it and this is how you can do it too.

For CPU Only:

If you don't have a GPU and want to use it on CPU, follow these steps:

  • Navigate to your folder.
  • Find the "webui-user.bat" file.
  • Left click on it and choose "Edit."
  • Look for the line that says "set commandline_args=" and add "--skip-torch-cuda-test" to it (should look like set commandline_args= --skip-torch-cuda-test).

If you have a gpu and want to use it:

All you need is an NVIDIA graphics card with at least 2 GB of memory. Some people say you need a card with more than 4 GB, but I have a card called MX300, which has 2 GB memory, and I can still use it without any issues for stable diffusion. The only drawback is that it takes 2 to 4 minutes to generate a picture, depending on a few factors. Btw there is a way to run it on AMD gpu too but I don’t know much about it.

Steps to use it on gpu:

  • First, download the special version of stable diffusion made for GPU use. You can find it here: https://github.com/automatic1111/stable-diffusion-webui/wiki/install-and-run-on-nvidia-gpus it also tells u how to download and use it but it is outdated information.
  • Open the downloaded folder and find the "run.bat" file.
  • Double-click on it and it will download torch with cuda enabled if it is just torch than go to step 3 btw I prefer you doing step 3 even if it downloading with cuda. As by default it downloads the old version of torch.

Step 3:

  • Before downloading "torch," close the file you are working on.

  • Go to this website: https://pytorch.org/get-started/previous-versions/

  • Find the right version of "torch" for your device on that website.

  • Open the Command Prompt (cmd).

  • Copy the path of the "run.bat" file.

  • Paste the path into the Command Prompt.

  • Add "-m" and the command for "torch" that you got from the website. It should look like this: "pathtothefile -m pip install torch==1.13.0+cu116..."

  • Now, run the command.

After the process is complete just run the "run.bat" file again and it will download some necessary library and after that you can use it.

Note:

The reason why people who have gpu but still cant run them on stable diffusion is that they have the wrong version of it and if you have more than one GPU and want to use a specific one of them go to the "webui-user.bat" file and add this line to it "set cuda_visible_devices=1" below the "set commandline_args=". By default stable diffusion will use the best GPU on its own but its a optional step and I don't think it will be nessary but if you still face problem using it on gpu you need to download CUDA from NVIDEA website on you computer It's the only remaining solution to try. It is also a good approach to have it installed on you Computer if you are using any A.I related model

@guilleCM
Copy link

guilleCM commented Aug 11, 2023

Error: RuntimeError: Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check

The solution for me was:

1- Download Geforce Experience 2- Download and update drivers using Geforce Experience app 3- run webui-user.bat again (no changes)

os: Windows 11, gpu: RTX 3060 12GB, drivers: 536.67

You save my day <3
Worked for me on Windows 10, NVIDIA GeForce RTX 2070, Driver Version: 536.99, CUDA Version: 12.2

@catboxanon catboxanon added asking-for-help-with-local-system-issues This issue is asking for help related to local system; please offer assistance and removed bug-report Report of a bug, yet to be confirmed labels Aug 26, 2023
@assanee
Copy link

assanee commented Jan 5, 2024

Error: RuntimeError: Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check

The solution for me was:

1- Download Geforce Experience 2- Download and update drivers using Geforce Experience app 3- run webui-user.bat again (no changes)

os: Windows 11, gpu: RTX 3060 12GB, drivers: 536.67

Worked for me on Windows 10, NVIDIA GeForce GTX 1050

@asleepace
Copy link

What worked for me on Windows 11, AMD Ryzen 5700U + Radeon Graphics was the following:

webui.bat --skip-torch-cuda-test --use-directml --medvram

Also turned down the CFG scale to 5 (which seems to have helped)

@GreedJar8
Copy link

Error: RuntimeError: Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check

The solution for me was:

1- Download Geforce Experience 2- Download and update drivers using Geforce Experience app 3- run webui-user.bat again (no changes)

os: Windows 11, gpu: RTX 3060 12GB, drivers: 536.67

Thank you, it worked for my 3060 too, but unfortunately it lost performance, don't do it now if possible, at least in this update now it loses performance on SD. To return the drive you can go to device manager and there you have the option to go to the previous drive but in fact it will return to the factory drive, from 2021, but the performance still returns

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
asking-for-help-with-local-system-issues This issue is asking for help related to local system; please offer assistance
Projects
None yet
Development

No branches or pull requests