CompVis / latent-diffusion

High-Resolution Image Synthesis with Latent Diffusion Models

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NameError: name 'trainer' is not defined

liuyangyu2003 opened this issue · comments

Traceback (most recent call last):
File "/root/autodl-tmp/LDM/main.py", line 535, in
model = instantiate_from_config(config.model)
File "/root/miniconda3/envs/ldm/lib/python3.8/site-packages/omegaconf/dictconfig.py", line 353, in getattr
self._format_and_raise(
File "/root/miniconda3/envs/ldm/lib/python3.8/site-packages/omegaconf/base.py", line 190, in _format_and_raise
format_and_raise(
File "/root/miniconda3/envs/ldm/lib/python3.8/site-packages/omegaconf/_utils.py", line 821, in format_and_raise
_raise(ex, cause)
File "/root/miniconda3/envs/ldm/lib/python3.8/site-packages/omegaconf/_utils.py", line 719, in _raise
raise ex.with_traceback(sys.exc_info()[2]) # set end OC_CAUSE=1 for full backtrace
File "/root/miniconda3/envs/ldm/lib/python3.8/site-packages/omegaconf/dictconfig.py", line 351, in getattr
return self._get_impl(key=key, default_value=DEFAULT_MARKER)
File "/root/miniconda3/envs/ldm/lib/python3.8/site-packages/omegaconf/dictconfig.py", line 438, in _get_impl
node = self._get_node(key=key, throw_on_missing_key=True)
File "/root/miniconda3/envs/ldm/lib/python3.8/site-packages/omegaconf/dictconfig.py", line 470, in _get_node
raise ConfigKeyError(f"Missing key {key}")
omegaconf.errors.ConfigAttributeError: Missing key model
full_key: model
object_type=dict

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/root/autodl-tmp/LDM/main.py", line 740, in
if trainer.global_rank == 0:
NameError: name 'trainer' is not defined
how can I sovle this problem?

Did you try with pytorch lightning==1.6.1? The problem arised for me when my pytorch lightning is 1.7.0 and above

The actual issue isn't with trainer being undefined, it's in the try block that precedes it. Remove all the code in the try block out of it, and rerun the code to see what the caught error is.

For me it was FileNotFoundError: [Errno 2] No such file or directory: 'configs/first_stage_models/vq-f4/model.yaml' which I fixed with this: #87 (comment)

Did you try with pytorch lightning==1.6.1? The problem arised for me when my pytorch lightning is 1.7.0 and above

my pytorch_lightning==1.4.2,and I try with pytorch lightning==1.6.1 ,however it didn't work

How fix it? It confuse me a lot.