Dreambooth-Stable-Diffusion icon indicating copy to clipboard operation
Dreambooth-Stable-Diffusion copied to clipboard

NameError: name 'trainer' is not defined

Open ffdown opened this issue 2 years ago • 5 comments

Traceback (most recent call last): File "E:\ai\sd\dbsdo\main.py", line 643, in model = load_model_from_config(config, opt.actual_resume) File "E:\ai\sd\dbsdo\main.py", line 30, in load_model_from_config model = instantiate_from_config(config.model) File "E:\ai\sd\dbsdo\ldm\util.py", line 86, in instantiate_from_config return get_obj_from_str(config["target"])(**config.get("params", dict()), **kwargs) File "E:\ai\sd\dbsdo\ldm\util.py", line 94, in get_obj_from_str return getattr(importlib.import_module(module, package=None), cls) File "E:\Anaconda3\lib\importlib_init_.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1030, in _gcd_import File "", line 1007, in _find_and_load File "", line 986, in _find_and_load_unlocked File "", line 680, in _load_unlocked File "", line 850, in exec_module File "", line 228, in _call_with_frames_removed File "E:\ai\sd\dbsdo\ldm\models\diffusion\ddpm.py", line 26, in from ldm.models.autoencoder import VQModelInterface, IdentityFirstStage, AutoencoderKL File "E:\ai\sd\dbsdo\ldm\models\autoencoder.py", line 6, in from taming.modules.vqvae.quantize import VectorQuantizer2 as VectorQuantizer ImportError: cannot import name 'VectorQuantizer2' from 'taming.modules.vqvae.quantize' (E:\Anaconda3\lib\site-packages\taming\modules\vqvae\quantize.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "E:\ai\sd\dbsdo\main.py", line 860, in if trainer.global_rank == 0: NameError: name 'trainer' is not defined

ffdown avatar Sep 30 '22 14:09 ffdown

what's the code that gave you this error

MaxisAI avatar Sep 30 '22 18:09 MaxisAI

same error here. Running the training step

python main.py --base configs/stable-diffusion/v1-finetune_unfrozen.yaml 
                -t 
                --actual_resume /path/to/original/stable-diffusion/sd-v1-4-full-ema.ckpt  
                -n <job name> 
                --gpus 0, 
                --data_root /root/to/training/images 
                --reg_data_root /root/to/regularization/images 
                --class_word <xxx>

image

I think the issue is the main.py is wrapped in a massive try catch and if there is an exception before defining the trainer instance, well, it just explodes with a non descriptive error.

In my case, the TestTubeLogger setup by default in this repo config is not supported anymore by pytorch lighting.

Changing this line and this line to CSVLogger

UPDATE just do yourself a favor and install a fairly old version of pytorch lighting 1.5.9, it will fix this issue and other ones you will see.

manugarri avatar Oct 03 '22 09:10 manugarri

I am having this exact same error code, however installing the older version of pytorch-lightning hasn't fixed the issue. any other ideas would be much appreciated!!

Tjplump avatar Oct 05 '22 19:10 Tjplump

Deleting the Conda Enviroment, reinstalling SD, and copying(replacing some 70ish files) the dreambooth repo into the SD one fixed it for me.

davidmcw289 avatar Oct 15 '22 23:10 davidmcw289

@davidmcw289 hi. I have same ıssue. How could you solve this? Can you tell it more detail, please. I dont understand now. Thank you

MesutUnutur avatar Mar 27 '23 08:03 MesutUnutur