LambdaLabsML / examples

Deep Learning Examples
MIT License
805 stars 103 forks source link

Keep getting: NameError: name 'trainer' is not defined #50

Open nulone opened 1 year ago

nulone commented 1 year ago

Run training

!(python main.py \ -t \ --base configs/stable-diffusion/pokemon.yaml \ --gpus "$gpu_list" \ --scale_lr False \ --num_nodes 1 \ --check_val_every_n_epoch 10 \ --finetune_from "$ckpt_path" \ data.params.batch_size="$BATCH_SIZE" \ lightning.trainer.accumulate_grad_batches="$ACCUMULATE_BATCHES" \ data.params.validation.params.n_gpus="$NUM_GPUS" \ )

Global seed set to 23 Running on GPUs 0,1, Traceback (most recent call last): File "main.py", line 670, in model = instantiate_from_config(config.model) File "/home/stable-diffusion/ldm/util.py", line 79, in instantiate_from_config return get_obj_from_str(config["target"])(**config.get("params", dict())) File "/home/stable-diffusion/ldm/util.py", line 87, in get_obj_from_str return getattr(importlib.import_module(module, package=None), cls) File "/opt/conda/lib/python3.8/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 975, in _find_and_load_unlocked File "", line 671, in _load_unlocked File "", line 843, in exec_module File "", line 219, in _call_with_frames_removed File "/home/stable-diffusion/ldm/models/diffusion/ddpm.py", line 26, in from ldm.models.autoencoder import VQModelInterface, IdentityFirstStage, AutoencoderKL File "/home/stable-diffusion/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' (/opt/conda/lib/python3.8/site-packages/taming/modules/vqvae/quantize.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "main.py", line 935, in if trainer.global_rank == 0: NameError: name 'trainer' is not defined

WhiteZz1 commented 1 year ago

me too

rorycochrane commented 1 year ago

What hardware are you running on? I had this issue at one point and I believe it was caused by the script specifying 2 GPUs when I was running on 1. I changed that line and it went away.