toshiaki1729 / dataset-tag-editor-standalone

WebUI to edit dataset captions for txt2img models
MIT License
129 stars 13 forks source link

CUDA device is not used #9

Closed dramumard closed 1 year ago

dramumard commented 1 year ago

I have a working NVIDIA GPU of Ampere generation. AUTOMATIC1111 and other projects have no problem using the CUDA device, but not dataset-tag-editor-standalone (for automatic captioning).

Windows 11 NVIDIA RTX A4500 NVIDIA Driver 528.95 tag editor on latest commit (024966c1addeb847729db53da1510cf98dc9ae2b)

dramumard commented 1 year ago

Issue solved, dataset-tag-editor-standalone is installing a too old version of CUDA.

My guess was that your install.bat script is not installing pytorch with CUDA support. I went to the pytorch site and looked up the recommended install command. Ofc I activated the virtual environment first.

On this page it says:

pip3 install numpy --pre torch --force-reinstall --index-url https://download.pytorch.org/whl/nightly/cu117

Note this installs a version for CUDA 11.7.

But still the only the CPU was used.

Later down on the same page though, in the FAQ, there is also a different install command that uses CUDA 11.8:

pip3 install numpy --pre torch torchvision torchaudio --force-reinstall --index-url https://download.pytorch.org/whl/nightly/cu118

And now it works, CUDA is detected and used.

I recommend adjusting the standalone dataset-tag-editor's install scripts to use CUDA 11.8.

toshiaki1729 commented 1 year ago

As mentioned in Requirements section, this script requires pre-installed PyTorch (this doesn't check nor manage PyTorch version). Or, if you want to re-install PyTorch in venv, you can use --force-install-torch command line argument.

pylorak commented 1 year ago

You're right, I'm sorry. Apparently I subconsciously skipped the requirements: saw "Installation", for Windows "Just run install.bat", and I was done reading :)

jibbersmcgee commented 1 year ago

I've got the same issue however i have cuda 12.1, pytorch 2.0. any ideas?

toshiaki1729 commented 1 year ago

I've got the same issue however i have cuda 12.1, pytorch 2.0. any ideas?

@jibbersmcgee Here you can see whether the PyTorch is installed with CUDA properly or not. ss

If your PyTorch version is without +cu117 or +cu118, you may need to re-install PyTorch.

CUDA Toolkit is not needed I think.

jibbersmcgee commented 1 year ago

Thank you. The launch CMD window says my device is CPU but it is actually using the video card.

On Wed, May 17, 2023, 8:19 AM toshiaki1729 @.***> wrote:

I've got the same issue however i have cuda 12.1, pytorch 2.0. any ideas?

Here you can see whether the PyTorch is installed with CUDA properly or not. [image: ss] https://user-images.githubusercontent.com/116595002/238940090-67b713a5-f7c8-4a02-86a1-b0e33477bf8d.png

If your PyTorch version is without +cu117 or +cu118, you may need to re-install PyTorch.

  • If You want to install PyTorch in your system and use it (to share PyTorch with other scripts)
    1. Follow the PyTorch installation guide https://pytorch.org/get-started/locally/ with -U (--upgrade) option (example) pip3 install -U torch torchvision --index-url https://download.pytorch.org/whl/cu118
    2. Remove venv folder
    3. Run install.bat
  • If you want to install PyTorch only in venv
    1. Open launch_user.bat to edit
    2. set COMMANDLINE_ARGS="--force-install-torch cu118" (you can choose from cu117, cu118 or cpu)

— Reply to this email directly, view it on GitHub https://github.com/toshiaki1729/dataset-tag-editor-standalone/issues/9#issuecomment-1551290864, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJIMA66YPYMJHOUNKYF7R3DXGS653ANCNFSM6AAAAAAYBHOL54 . You are receiving this because you commented.Message ID: @.*** com>

toshiaki1729 commented 1 year ago

The launch CMD window says my device is CPU but it is actually using the video card.

Ah, are you using WD v1.4 tagger? It doesn't use PyTorch.

jibbersmcgee commented 1 year ago

Yes I'm using WD. Maybe I'm misunderstanding. The device is listed as cpu but when i run the tagger, my GPU usage is 100% and it's very quick. It's working just fine but maybe there's something i don't understand.

On Wed, May 17, 2023, 9:06 PM toshiaki1729 @.***> wrote:

The launch CMD window says my device is CPU but it is actually using the video card.

Ah, are you using WD v1.4 tagger? It doesn't use PyTorch.

— Reply to this email directly, view it on GitHub https://github.com/toshiaki1729/dataset-tag-editor-standalone/issues/9#issuecomment-1552269025, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJIMA63GHZEPEMIWRZBNQ5TXGVYYLANCNFSM6AAAAAAYBHOL54 . You are receiving this because you were mentioned.Message ID: @.*** com>

azumukupoe commented 1 year ago

@toshiaki1729 replaced the third line in launch_user.bat with set COMMANDLINE_ARGS="--force-install-torch cu118" and got this: launch.py: error: unrecognized arguments: --force-install-torch cu118