numz / sd-wav2lip-uhq

Wav2Lip UHQ extension for Automatic1111
Apache License 2.0
1.16k stars 158 forks source link

The Fix for Torch and GPU problem #86

Open APCOTech opened 8 months ago

APCOTech commented 8 months ago

For those who got their webUI corrupted after installing sd-wav2lip-uhq extension, here is how to fix it:

1) download this file: torchaudio-2.0.2+cu118-cp310-cp310-win_amd64.whl from https://download.pytorch.org/whl/torchaudio or https://mirror.sjtu.edu.cn/pytorch-wheels/cu118/?mirror_intel_list and save it anywhere for now... lets assume you will save it in D:\

2) if you did not install sd-wav2lip-uhq yet, then go to the extensions tab and install it normally, it will corrupt the venv anyway... but do not click on (apply and restart). when webUI asks you to restart, just close it and close the command prompt.

3) browse to your A1111 installation foloder and go to X:\stable-diffusion-webui\extensions\sd-wav2lip-uhq

4) Edit the requirement.txt to this only: imutils dlib-bin numpy opencv-python scipy requests pillow librosa==0.10.0.post2 opencv-contrib-python tqdm numba imutils imageio_ffmpeg git+https://github.com/suno-ai/bark.git insightface==0.7.3 onnx==1.14.0 onnxruntime-gpu==1.15.0 ifnude

5) run webUI normally, it will collapse again... so close the command prompt

6) browse to X:\stable-diffusion-webui\venv\Lib\site-packages and run a command prompt

7) run these two commands in the command prompt .\python.exe -m pip install torch==2.0.1+cu118 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

then install the .whl you downloaded in step 1 .\python.exe -m pip install "D:\torchaudio-2.0.2+cu118-cp310-cp310-win_amd64.whl"

8) Done... Enjoy...

APCOTech commented 8 months ago

image

image

Testing.....

APCOTech commented 8 months ago

and it took almost 6 minutes....

https://github.com/numz/sd-wav2lip-uhq/assets/23286083/fadd37bd-1181-4f3e-8414-d599a12b5489

P-Elendil commented 8 months ago

Followed the steps above but sadly still getting RuntimeError: Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check

prezofpizza commented 8 months ago

This worked for me! Thank you so much!

I first activated the virtual environment before running the command lines pasted above, that seems to be the difference maker.

prezofpizza commented 8 months ago

Followed the steps above but sadly still getting RuntimeError: Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check

Be sure to run the commands in the virtual environment, that seems to have worked for me.

imdaewoong commented 8 months ago

sadly still getting RuntimeError.... me too. i tried six times. all them Error

APCOTech commented 8 months ago

Followed the steps above but sadly still getting RuntimeError: Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check

" Torch is not able to use GPU" mean that you still have torch2.1 ... did you edit the requirements.txt file to remove onnxruntime==1.15.0??

In your stable-diffusion-webui\venv\Lib\site-packages... scroll down and check which torch you have.. it should be like this to work

image if it is not , then may be you did something wrong .

P-Elendil commented 8 months ago

Followed the steps above but sadly still getting RuntimeError: Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check

Be sure to run the commands in the virtual environment, that seems to have worked for me.

yep this was it. Thank you! All working now.

APCOTech commented 8 months ago

This worked for me! Thank you so much!

I first activated the virtual environment before running the command lines pasted above, that seems to be the difference maker.

yeah I forgot to type that, I wrote it quickly

nogutsnoglorious commented 8 months ago

I'm still having the issue. I don't understand what this means:

Be sure to run the commands in the virtual environment, that seems to have worked for me.

I've followed all the steps a few times. I have all the torch folders installed in stable-diffusion-webui\venv\Lib\site-packages. What am I doing wrong? Also I have such text when executing WebUI: image

APCOTech commented 8 months ago

Did you install the extension using (git clone https://github.com/numz/sd-wav2lip-uhq) ?? I think you need to install the extension normally from Automatic1111 first then follow the steps.

nogutsnoglorious commented 8 months ago

Did you install the extension using (git clone https://github.com/numz/sd-wav2lip-uhq) ?? I think you need to install the extension normally from Automatic1111 first then follow the steps.

I deleted the folder and installed it via command git clone https://github.com/numz/sd-wav2lip-uhq. The error above in the screenshot disappeared. But torch error remains. Any ideas what to do? Maybe reinstall venv folder for SD? (I saw this step in other ussues, I did it earlier too, but that didn't help.

This issue messed up my whole workday.

nogutsnoglorious commented 8 months ago

Unfortunately, this doesn't work even for a clean newly installed SD.

haihanZhou commented 8 months ago

Hello @APCOTech, thank you very much for sharing!

I guess what we are trying to do is to force the torch fall back from 2.1.0 to 2.0.1 and torchaudio to 2.0.2. However, I am also seeing issues even if I did what you described. For some reason, the torch is still 2.1.0.

My stack: Windows 11, Anaconda, VS code, 4090, cuda11.8

what I did:

  1. launch Anaconda Navigator --> VS Code
  2. Create an environment called "SD-test", with python = 3.10.6
  3. Git clone Automatic1111/stable-diffusion-webui.git
  4. run webui-user.bat

    Up to now, webui is functioning and I can use my GPU

  5. Go to extension --> install from URL --> install wav2lip-uhq
  6. stderr: ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'E:\SD-test\venv\Lib\site-packages\cv2\cv2.pyd' Check the permissions.
  7. However, when I restart webui, the wav2lip tab is there, seems like installed properly. Update on this error: I tried to install another extension ControlNet, it gives me the same error, but when I restart it Torch was able to use GPU, everything seems normal.
  8. When I close the webui again and try to start, I see 'Torch is not able to use GPU'
  9. Then I closed the window and did what you mentioned above. I got the following in the 'site-packages': issue

Could you provide any insights/walk-around regarding my situation?

APCOTech commented 8 months ago

Hello @APCOTech, thank you very much for sharing!

I guess what we are trying to do is to force the torch fall back from 2.1.0 to 2.0.1 and torchaudio to 2.0.2. However, I am also seeing issues even if I did what you described. For some reason, the torch is still 2.1.0.

My stack: Windows 11, Anaconda, VS code, 4090, cuda11.8

what I did:

1. launch **Anaconda Navigator** --> **VS Code**

2. Create an environment called "SD-test", with python = 3.10.6

3. Git clone Automatic1111/stable-diffusion-webui.git

4. run webui-user.bat

Up to now, webui is functioning and I can use my GPU

5. Go to extension --> install from URL --> install wav2lip-uhq

6. **stderr: ERROR**: Could not install packages due to an **OSError: [WinError 5]** Access is denied: 'E:\SD-test\venv\Lib\site-packages\cv2\cv2.pyd' Check the permissions.

7. However, when I restart webui, the **wav2lip tab is there**, seems like installed properly. **Update on this error: I tried to install another extension ControlNet, it gives me the same error, but when I restart it Torch was able to use GPU, everything seems normal.**

8. When I close the webui again and try to start, I see '**Torch is not able to use GPU**'

9. Then I closed the window and did what you mentioned above. I got the following in the 'site-packages':
   ![issue](https://user-images.githubusercontent.com/106989336/282170321-da8f4d9c-d104-459f-b13e-5f7c422b9d8f.png)

Could you provide any insights/walk-around regarding my situation?

I think you need to make sure that you removed (onnxruntime==1.15.0 - opencv-python>=4.8.0) from the requirements.txt

also, I found out that bark is getting installed everytime you run webUI ... you can test that by disconnect internet then run webUI ...For me, I removed the git+https://github.com/suno-ai/bark.git line too after it got installed the first time...

APCOTech commented 8 months ago

Unfortunately, this doesn't work even for a clean newly installed SD.

After clean install, install the extension from the Extensions tab as normal and make sure to follow the steps ... the webUI will break down twice but it will work perfect after that.. make sure to Activate venv before step 9

nogutsnoglorious commented 7 months ago

Is there any workaround? Why standard installation as it used to be, turns into hell of a journey? I've already reinstalled all of my extensions. I don't want to go through this once again.

APCOTech commented 7 months ago

Is there any workaround? Why standard installation as it used to be, turns into hell of a journey? I've already reinstalled all of my extensions. I don't want to go through this once again.

This is the workaround so you do not install anything again... https://github.com/numz/sd-wav2lip-uhq/issues/86#issue-1984431053

just follow the steps and you will be fine.. and in step 7, activate venv first (from the venv\scripts\ folder)

Maki9009 commented 7 months ago

i keep getting this when i start to generate,

Reading video frames... Number of frames available for inference: 150 (80, 573) Length of mel chunks: 176 0%| | 0/10 [00:10<?, ?it/s] Recovering from OOM error; New batch size: 8 | 0/10 [00:00<?, ?it/s] 0%| | 0/19 [00:07<?, ?it/s] Recovering from OOM error; New batch size: 4 | 0/19 [00:00<?, ?it/s]

0%| | 0/38 [00:00<?, ?it/s]

And it just stuck like this

APCOTech commented 7 months ago

i keep getting this when i start to generate,

Reading video frames... Number of frames available for inference: 150 (80, 573) Length of mel chunks: 176 0%| | 0/10 [00:10<?, ?it/s] Recovering from OOM error; New batch size: 8 | 0/10 [00:00<?, ?it/s] 0%| | 0/19 [00:07<?, ?it/s] Recovering from OOM error; New batch size: 4 | 0/19 [00:00<?, ?it/s]

0%| | 0/38 [00:00<?, ?it/s]

And it just stuck like this

@Maki9009 Try to change Resize Factor to 2 or higher.. 2 works fine with me

bstuart999 commented 7 months ago

This is the problem:

image

I've done multiple reinstalls, followed the OP's advice exactly every time and it doesn't work. He's be must missing steps. Even tried the activate.bat in venv, which he mentions down later in the comments. Does nothing, same errors.

I also tried the below advice from another post, which also doesn't work, but maybe others will have success. It simply resulted in a frozen generation after 30+ minutes. (This is on a 4090). Seems we'll have to wait for an update.

You can install previous version : In a cmd Go to "extensions\sd-wav2lip-uhq" folder And type : "git checkout https://github.com/numz/sd-wav2lip-uhq/commit/2283dacdbf0b215fb05e9a18ed828a78d01ef55d" for no bark and no face swap "git checkout https://github.com/numz/sd-wav2lip-uhq/commit/579d384aa95c4711a0c3b6dcf08378bafb4ba5a3" for no face swap

Geo-Joy commented 7 months ago

So here is the flow that worked for me. 1) install Automatic1111 2) Install the extension and restart Automatic1111 3) This time after the new plugin is installed u get the torch error 4) open a fresh terminal -> manuall switch to venv and install - ref screenshot below python.exe -m pip install torch==2.0.1+cu118 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

image

5) Download torchaudio-2.0.2+cu118-cp310-cp310-win_amd64.whl from from this url https://download.pytorch.org/whl/torchaudio place it in the main stable diffusion folder itself 6) Install this package (it might say its already installed) fine... image

7) Invoke webui-user.bat - it might seem frozen but its fine... give it some min... image

8) It Works!!! image

ActionStripes commented 7 months ago

Geo-Joy's post above worked perfectly for me. Thanks!

danielflam commented 6 months ago

I followed the instructions but now after i run I set up the video and audio and then the program crashes boom:

To create a public link, set share=True in launch(). Startup time: 54.7s (prepare environment: 20.2s, import torch: 2.1s, import gradio: 0.7s, setup paths: 4.3s, initialize shared: 0.1s, other imports: 0.4s, load scripts: 23.8s, create ui: 2.6s, gradio launch: 0.4s). Applying attention optimization: Doggettx... done. Model loaded in 5.3s (load weights from disk: 0.4s, create model: 0.3s, apply weights to model: 4.4s, calculate empty prompt: 0.1s). Using cuda for inference. Reading video frames... Number of frames available for inference: 104 LLVM ERROR: Symbol not found: __svml_cosf8_ha Press any key to continue . . .

I am using the standalone version SD webui with above instructions I tried this on 3 different branches of the program.

dairydaddy commented 6 months ago

I've replaced the requirements.txt in the sd-wav2lip-uhq folder, and A1111 loads... but the Wav2Lip tab isn't showing. Is there a specific cause / fix for that?

SamPorter69 commented 5 months ago

Followed the steps above but sadly still getting RuntimeError: Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check

Be sure to run the commands in the virtual environment, that seems to have worked for me.

How I am do this? Running the commands in the virtual environment?

Safira123123 commented 3 months ago

Fucking trash extension still here I misclicked on the install button for that shit and now have to endure headache again

jonk999 commented 2 months ago

Followed the directions by both @APCOTech and @Geo-Joy and unfortunately no joy for me. Is there a specific version of Automatic1111 to run? I don't seem to get the same torch folders as mentioned. I end up with the following even though there don't appear to be any errors when running the commands. Just a lot of 'Requirement already satisfied'. image

I also tried tried a previous commit by downloading a previous commit (https://github.com/numz/sd-wav2lip-uhq/commit/2c8f2aead11633086501fadc8457108e26a5f225), amending the requirements file and running. It loaded once but then when I tried doing a generation, got an error and then when I restated Auto1111 the Torch is not able to use GPU error was back.

Wondering if there are suggestions of what else to try? I saw in another thread that someone 'uninstalled torch torchvison torchaudio and reinstalled the version corresponding to cuda cudnn', but am not sure how to do that.

BBCOT commented 2 months ago

run these two commands in the command prompt .\python.exe -m pip install torch==2.0.1+cu118 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

How to fix ?

ERROR: Could not find a version that satisfies the requirement torch==2.0.1+cu118 (from versions: 2.2.0+cu118, 2.2.1+cu118, 2.2.2+cu118, 2.3.0+cu118)

jonk999 commented 1 month ago

I ended up downloading code for Auto1111 1.5.2 and installing that then following the install directions and it seems to now be working. I just won't update Auto1111. I have another up to date version that I use for other generations.

ruansclipet commented 1 month ago

guys the webui is opening, but it's not showing the Wav2Lip Studio tab? any help how can I solve this?

ruansclipet commented 1 month ago

Captura de tela 2024-06-07 180905 I keep having this problem, anyone know how can I solve it?