ControlNet icon indicating copy to clipboard operation
ControlNet copied to clipboard

No module 'xformers'. Proceeding without it.

Open ppeterpp opened this issue 1 year ago • 3 comments

Simply running pip install xformers would overwrite the existing pytorch 1.12.1, so which version of xformers should I choose?

ppeterpp avatar Dec 14 '23 07:12 ppeterpp

Hello,do you address this problem?

feifeitu1 avatar Dec 21 '23 04:12 feifeitu1

I did the following:

conda create --name xcontrol python=3.9

then I installed xformers and torchvision for cuda 11.8 (since I am running that version)

pip3 install -U xformers torchvision --index-url https://download.pytorch.org/whl/cu118

and modified the yaml file a bit and ran conda env update --name xcontrol --file environment_X.yaml

name: xcontrol
channels:
  - pytorch
  - defaults
dependencies:
  - pip:
      - gradio==3.16.2
      - albumentations==1.3.0
      - opencv-contrib-python==4.9.0.80
      - imageio==2.9.0
      - imageio-ffmpeg==0.4.2
      - pytorch-lightning==2.2
      - omegaconf==2.1.1
      - test-tube>=0.7.5
      - streamlit==1.12.1
      - einops==0.3.0
      - transformers==4.19.2
      - webdataset==0.2.5
      - kornia==0.6
      - open_clip_torch==2.0.2
      - invisible-watermark>=0.1.5
      - streamlit-drawable-canvas==0.8.0
      - torchmetrics==0.7.0
      - timm==0.6.12
      - addict==2.4.0
      - yapf==0.32.0
      - prettytable==3.6.0
      - safetensors==0.2.7
      - basicsr==1.4.2

Since we will no longer be using the same version of libraries as the original repo (like torchmetrics and pytorch lightning) we also need to modify some of the files (you can just run the code and fix it after you get errors):

ControlNet/cldm/logger.py ControlNet/ldm/models/diffusion/ddpm.py

In both files we need to:

  1. delete dataloader_idx variable from the only function that has it
  2. change one line in the import section from pytorch_lightning.utilities.distributed to pytorch_lightning.utilities.rank_zero

and in tutorial_train.py file:

trainer = pl.Trainer(devices=1, accelerator="gpu", precision=32, callbacks=[logger])  # newer version of pl

I think that is all, hope it works :)

lukakeso avatar Feb 13 '24 12:02 lukakeso

Thanks, the solution above worked for me. The xformers warning is gone.

PerlMonker303 avatar Feb 13 '24 16:02 PerlMonker303