cdvae icon indicating copy to clipboard operation
cdvae copied to clipboard

evaluate.py error

Open ditto7284 opened this issue 6 days ago • 0 comments

The first question is whether I should run python scripts/evaluate.py --model_path MODEL_PATH --tasks recon gen opt or python scripts/evaluate.py --model_path MODEL_PATH --tasks recon gen opt model.predict_property=True when generating materials. Which one is correct? I trained the model with model.predict_property=True option.

The second question is about the model path. In my directory, both the checkpoint file and the hparams file are clearly present, but I'm getting an error saying they can't be read. When I set the model path to the model file, this error occurred.

/cdvae/HYDRA/singlerun/2025-02-20/250219-docker-gpu01-mp20 # ls
'epoch=464-step=49290-last.ckpt' 'epoch=594-step=63070-last.ckpt' 'epoch=774-step=82150-last.ckpt' 'epoch=809-step=85860-last.ckpt' lattice_scaler.pt run.log 'epoch=589-step=62540-last.ckpt' 'epoch=749-step=79500-last.ckpt' 'epoch=774-step=82150.ckpt' hparams.yaml prop_scaler.pt wandb

/cdvae python -W ignore scripts/evaluate.py \
--model_path /cdvae/HYDRA/singlerun/2025-02-20/250219-docker-gpu01-mp20/epoch=774-step=82150-last.ckpt
--tasks recon gen opt

Traceback (most recent call last): File "/cdvae/scripts/evaluate.py", line 280, in main(args) File "/cdvae/scripts/evaluate.py", line 178, in main model, test_loader, cfg = load_model( File "/cdvae/scripts/eval_utils.py", line 57, in load_model cfg = compose(config_name='hparams') File "/root/miniconda3/envs/cdvae/lib/python3.9/site-packages/hydra/experimental/compose.py", line 21, in compose return real_compose( File "/root/miniconda3/envs/cdvae/lib/python3.9/site-packages/hydra/compose.py", line 28, in compose cfg = gh.hydra.compose_config( File "/root/miniconda3/envs/cdvae/lib/python3.9/site-packages/hydra/_internal/hydra.py", line 564, in compose_config cfg = self.config_loader.load_configuration( File "/root/miniconda3/envs/cdvae/lib/python3.9/site-packages/hydra/_internal/config_loader_impl.py", line 146, in load_configuration return self._load_configuration_impl( File "/root/miniconda3/envs/cdvae/lib/python3.9/site-packages/hydra/_internal/config_loader_impl.py", line 227, in _load_configuration_impl self.ensure_main_config_source_available() File "/root/miniconda3/envs/cdvae/lib/python3.9/site-packages/hydra/_internal/config_loader_impl.py", line 134, in ensure_main_config_source_available self._missing_config_error( File "/root/miniconda3/envs/cdvae/lib/python3.9/site-packages/hydra/_internal/config_loader_impl.py", line 108, in _missing_config_error raise MissingConfigException( hydra.errors.MissingConfigException: Primary config directory not found. Check that the config directory '/cdvae/HYDRA/singlerun/2025-02-20/250219-docker-gpu01-mp20/epoch=774-step=82150-last.ckpt' exists and readable

To fix this, I set the model path to the directory name instead of the model file, but then I got the following error:

/cdvae # python scripts/evaluate.py \
--model_path /cdvae/HYDRA/singlerun/2025-02-20/250219-docker-gpu01-mp20/
--tasks recon gen opt

/root/miniconda3/envs/cdvae/lib/python3.9/site-packages/hydra/experimental/compose.py:16: UserWarning: hydra.experimental.compose() is no longer experimental. Use hydra.compose() warnings.warn( Traceback (most recent call last): File "/cdvae/scripts/evaluate.py", line 280, in main(args) File "/cdvae/scripts/evaluate.py", line 178, in main model, test_loader, cfg = load_model( File "/cdvae/scripts/eval_utils.py", line 70, in load_model model = model.load_from_checkpoint(ckpt, map_location=torch.device("cpu") if not torch.cuda.is_available() else None) File "/root/miniconda3/envs/cdvae/lib/python3.9/site-packages/pytorch_lightning/utilities/model_helpers.py", line 121, in wrapper raise TypeError( TypeError: The classmethod CDVAE.load_from_checkpoint cannot be called on an instance. Please call it on the class type and make sure the return value is used.

How can I fix the problem? Please answer me.

ditto7284 avatar Feb 21 '25 07:02 ditto7284