Dreambooth-Stable-Diffusion
Dreambooth-Stable-Diffusion copied to clipboard
NameError: name 'trainer' is not defined
I get this error after running the step after "Edit the personalized.py file" specifically #START THE TRAINING
Traceback (most recent call last):
File "C:\Users\Fealix\stable-diffusion-webui\dreambooth\Dreambooth-Stable-Diffusion\main.py", line 869, in
The codeblock that contains this line in the traceback reads as follows
move newly created debug project to debug_runs
if opt.debug and not opt.resume and trainer.global_rank == 0:
dst, name = os.path.split(logdir)
dst = os.path.join(dst, "debug_runs", name)
os.makedirs(os.path.split(dst)[0], exist_ok=True)
os.rename(logdir, dst)
if trainer.global_rank == 0: <---------- This is line 869 in my main.py
print("Training complete. max_training_steps reached or we blew up.")
# print(trainer.profiler.summary())
This is an issue that is not isolated to my installation either. Aitrepreneur mentions it in his video on Youtube ( https://www.youtube.com/watch?v=TgUrA1Nq4uE ) at timestamp 4:27 ish.
Please let me know if I can assist further with more information. I am going to reinstall but keep my old install around for the purposes of troubleshooting this error.
Just got this as well but not sure the source is the same
Traceback (most recent call last):
File "main.py", line 670, in <module>
model = load_model_from_config(config, opt.actual_resume)
File "main.py", line 30, in load_model_from_config
pl_sd = torch.load(ckpt, map_location="cpu")
File "/opt/conda/lib/python3.7/site-packages/torch/serialization.py", line 699, in load
with _open_file_like(f, 'rb') as opened_file:
File "/opt/conda/lib/python3.7/site-packages/torch/serialization.py", line 230, in _open_file_like
return _open_file(name_or_buffer, mode)
File "/opt/conda/lib/python3.7/site-packages/torch/serialization.py", line 211, in __init__
super(_open_file, self).__init__(open(name, mode))
FileNotFoundError: [Errno 2] No such file or directory: 'model.ckpt'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 888, in <module>
if trainer.global_rank == 0:
NameError: name 'trainer' is not defined
You do not have stable diffusion model downloaded to directory of the repo :) You need have model.ckpt in folder. @Mozoloa
I've always had it since I'm using the same environment since the beginning, that wasn't the glitch.
Apparently, shutting down the kernel and turning it back on was the solution ? odd
folder ./src/taming_transformers wasn't downloaded.
try to make your library version same as in enviroment.yaml file
dependencies:
- python=3.8.10
- pip=20.3
- cudatoolkit=11.3
- pytorch=1.10.2
- torchvision=0.11.3
- numpy=1.22.3
- pip:
- albumentations==1.1.0
- opencv-python==4.2.0.34
- pudb==2019.2
- imageio==2.14.1
- imageio-ffmpeg==0.4.7
- pytorch-lightning==1.5.9
- omegaconf==2.1.1
- test-tube>=0.7.5
- streamlit>=0.73.1
- setuptools==59.5.0
- pillow==9.0.1
- einops==0.4.1
- torch-fidelity==0.3.0
- transformers==4.18.0
- torchmetrics==0.6.0
- kornia==0.6
- -e git+https://github.com/CompVis/taming-transformers.git@master#egg=taming-transformers
- -e git+https://github.com/openai/CLIP.git@main#egg=clip
- -e .
Got the same error, and could not find a way to fix it:
File "/venv/lib/python3.10/site-packages/torch/cuda/init.py", line 217, in _lazy_init torch._C._cuda_init() RuntimeError: No CUDA GPUs are available
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/workspace/Dreambooth-Stable-Diffusion/main.py", line 896, in
Looks like you are using python 3.10, try python=3.8.10
How can I do it when using colab notebook ?
Potentially related (NameError: name 'trainer' is not defined
):
- https://github.com/JoePenna/Dreambooth-Stable-Diffusion/issues/28
- https://github.com/JoePenna/Dreambooth-Stable-Diffusion/issues/53
- https://github.com/JoePenna/Dreambooth-Stable-Diffusion/issues/86
- https://github.com/JoePenna/Dreambooth-Stable-Diffusion/issues/87
I went to line 896 on Main.py, and changed "trainer" for "Trainer", now it's working
Originally posted by @Pegaxsus in https://github.com/JoePenna/Dreambooth-Stable-Diffusion/issues/86#issuecomment-1295861499