IOPaint icon indicating copy to clipboard operation
IOPaint copied to clipboard

[BUG] Lama-cleaner: error: torch.cuda.is_available() is False

Open ShmuelRonen opened this issue 2 years ago • 7 comments

Model Which model are you using? lama-cleaner: 1.2.0

Describe the bug Aftert I update Lama Cleaner I got an Error:

  • Platform: Windows-10-10.0.19045-SP0
  • Python version: 3.10.6
  • torch: 2.0.1
  • torchvision: 0.15.2
  • Pillow: 9.4.0
  • diffusers: 0.16.1
  • transformers: 4.27.4
  • opencv-python: 4.7.0.72
  • xformers: N/A
  • accelerate: 0.17.1
  • lama-cleaner: 1.2.0
  • rembg: N/A
  • realesrgan: N/A
  • gfpgan: N/A

2023-06-07 11:09:03.954 | INFO | lama_cleaner.parse_args:parse_args:193 - Loading installer config from D:\Lama Cleaner\lama-cleaner\win_start.bat..\installer_config.json usage: lama-cleaner [-h] [--host HOST] [--port PORT] [--config-installer] [--load-installer-config] [--installer-config INSTALLER_CONFIG] [--model {lama,ldm,zits,mat,fcf,sd1.5,anything4,realisticVision1.4,cv2,manga,sd2,paint_by_example,instruct_pix2pix}] [--no-half] [--cpu-offload] [--disable-nsfw] [--sd-cpu-textencoder] [--sd-controlnet] [--sd-controlnet-method {control_v11p_sd15_canny,control_v11p_sd15_openpose,control_v11p_sd15_inpaint,control_v11f1p_sd15_depth}] [--sd-local-model-path SD_LOCAL_MODEL_PATH] [--local-files-only] [--enable-xformers] [--device {cuda,cpu,mps}] [--gui] [--no-gui-auto-close] [--gui-size GUI_SIZE GUI_SIZE] [--input INPUT] [--output-dir OUTPUT_DIR] [--model-dir MODEL_DIR] [--disable-model-switch] [--quality QUALITY] [--enable-interactive-seg] [--interactive-seg-model {vit_b,vit_l,vit_h}] [--interactive-seg-device {cuda,cpu,mps}] [--enable-remove-bg] [--enable-anime-seg] [--enable-realesrgan] [--realesrgan-device {cpu,cuda,mps}] [--realesrgan-model {realesr-general-x4v3,RealESRGAN_x4plus,RealESRGAN_x4plus_anime_6B}] [--realesrgan-no-half] [--enable-gfpgan] [--gfpgan-device {cpu,cuda,mps}] [--enable-restoreformer] [--restoreformer-device {cpu,cuda,mps}] [--enable-gif] [--install-plugins-package] lama-cleaner: error: torch.cuda.is_available() is False, please use --device cpu or check your pytorch installation Press any key to continue . . .

In CMD I got this:

Microsoft Windows [Version 10.0.19045.2965] (c) Microsoft Corporation. All rights reserved.

C:\Users\derec>python Python 3.10.7 (tags/v3.10.7:6cc6b13, Sep 5 2022, 14:08:36) [MSC v.1933 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

import torch print(torch.version) 1.12.1+cu113 print(torch.cuda.is_available()) True

ShmuelRonen avatar Jun 07 '23 08:06 ShmuelRonen

I update Cuda and Torech but the error continue

Successfully installed torch-2.0.1+cu117

C:\Users\derec\OneDrive\Desktop\Deep_Fack>python Python 3.10.7 (tags/v3.10.7:6cc6b13, Sep 5 2022, 14:08:36) [MSC v.1933 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

import torch print(torch.version) 2.0.1+cu117 print(torch.cuda.is_available()) True

  • Platform: Windows-10-10.0.19045-SP0
  • Python version: 3.10.6
  • torch: 2.0.1
  • torchvision: 0.15.2
  • Pillow: 9.4.0
  • diffusers: 0.16.1
  • transformers: 4.27.4
  • opencv-python: 4.7.0.72
  • xformers: N/A
  • accelerate: 0.17.1
  • lama-cleaner: 1.2.0
  • rembg: N/A
  • realesrgan: N/A
  • gfpgan: N/A

2023-06-07 12:24:36.376 | INFO | lama_cleaner.parse_args:parse_args:193 - Loading installer config from D:\Lama Cleaner\lama-cleaner\win_start.bat..\installer_config.json usage: lama-cleaner [-h] [--host HOST] [--port PORT] [--config-installer] [--load-installer-config] [--installer-config INSTALLER_CONFIG] [--model {lama,ldm,zits,mat,fcf,sd1.5,anything4,realisticVision1.4,cv2,manga,sd2,paint_by_example,instruct_pix2pix}] [--no-half] [--cpu-offload] [--disable-nsfw] [--sd-cpu-textencoder] [--sd-controlnet] [--sd-controlnet-method {control_v11p_sd15_canny,control_v11p_sd15_openpose,control_v11p_sd15_inpaint,control_v11f1p_sd15_depth}] [--sd-local-model-path SD_LOCAL_MODEL_PATH] [--local-files-only] [--enable-xformers] [--device {cuda,cpu,mps}] [--gui] [--no-gui-auto-close] [--gui-size GUI_SIZE GUI_SIZE] [--input INPUT] [--output-dir OUTPUT_DIR] [--model-dir MODEL_DIR] [--disable-model-switch] [--quality QUALITY] [--enable-interactive-seg] [--interactive-seg-model {vit_b,vit_l,vit_h}] [--interactive-seg-device {cuda,cpu,mps}] [--enable-remove-bg] [--enable-anime-seg] [--enable-realesrgan] [--realesrgan-device {cpu,cuda,mps}] [--realesrgan-model {realesr-general-x4v3,RealESRGAN_x4plus,RealESRGAN_x4plus_anime_6B}] [--realesrgan-no-half] [--enable-gfpgan] [--gfpgan-device {cpu,cuda,mps}] [--enable-restoreformer] [--restoreformer-device {cpu,cuda,mps}] [--enable-gif] [--install-plugins-package] lama-cleaner: error: torch.cuda.is_available() is False, please use --device cpu or check your pytorch installation Press any key to continue . . .

ShmuelRonen avatar Jun 07 '23 09:06 ShmuelRonen

It seems that the Python environment where you installed torch 2.0.1+cu117 and launched lama-cleaner are not the same. Lama detected an environment with torch 2.0.1.

image

Sanster avatar Jun 07 '23 10:06 Sanster

This is not the main Installation it's a second one for vlad/automatic

C:\vlad\automatic>webui.bat --upgrade Using VENV: C:\vlad\automatic\venv 18:55:32-728924 INFO Starting SD.Next 18:55:32-732925 INFO Python 3.10.7 on Windows 18:55:32-813926 INFO Version: 2a664b1b Tue Jun 6 17:32:34 2023 -0400 18:55:33-384929 INFO Updating main repository 18:55:35-305927 INFO Upgraded to version: 3bef3e3e Wed Jun 7 17:25:11 2023 +0300 18:55:35-307925 INFO Setting environment tuning 18:55:35-311927 INFO nVidia CUDA toolkit detected 18:55:37-216925 INFO Torch 2.0.1+cu118 18:55:37-230925 INFO Torch backend: nVidia CUDA 11.8 cuDNN 8700 18:55:37-233925 INFO Torch detected GPU: NVIDIA GeForce RTX 3090 VRAM 24576 Arch (8, 6) Cores 82 18:55:37-235924 INFO Verifying requirements 18:55:37-247926 INFO Installing packages 18:55:37-249926 INFO Running setup 18:55:37-250933 INFO Installing repositories 18:55:41-734379 INFO Installing submodules 18:55:43-899379 INFO Updating submodules

ShmuelRonen avatar Jun 07 '23 14:06 ShmuelRonen

after i install Xformers...i get this error too...., reinstall still get the problems...

ken456789 avatar Jun 19 '23 16:06 ken456789

after i install Xformers...i get this error too...., reinstall still get the problems...

Different versions of xformers require different versions of PyTorch. Below are the tested version combinations that can be used. Perhaps it can solve your problem.

pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 --extra-index-url https://download.pytorch.org/whl/cu117
pip install xformers==0.0.16

Sanster avatar Jun 20 '23 00:06 Sanster

pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 --extra-index-url https://download.pytorch.org/whl/cu117 pip install xformers==0.0.16

In what version of Python?

ShmuelRonen avatar Jun 20 '23 04:06 ShmuelRonen

pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 --extra-index-url https://download.pytorch.org/whl/cu117 pip install xformers==0.0.16

In what version of Python?

python 3.10 should work

Sanster avatar Jun 24 '23 03:06 Sanster