Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModelCheckpoint.filepath cannot be None #1674

Closed
elkotito opened this issue Apr 30, 2020 · 1 comment
Closed

ModelCheckpoint.filepath cannot be None #1674

elkotito opened this issue Apr 30, 2020 · 1 comment
Labels
bug Something isn't working help wanted Open to be worked on

Comments

@elkotito
Copy link
Contributor

elkotito commented Apr 30, 2020

🐛 Bug

The ModelCheckpoint callback's argument filepath cannot be None even though the docs says:

Can also be set to None, then it will be set to default location during trainer construction.

The exception is raised:

Traceback (most recent call last):
  File "/home/pi3ni0/Workspace/random/siamese_cnn_glove.py", line 209, in <module>
    checkpoint_callback = ModelCheckpoint(
  File "/home/pi3ni0/.venv/dev/lib/python3.6/site-packages/pytorch_lightning/callbacks/model_checkpoint.py", line 89, in __init__
    if save_top_k > 0 and os.path.isdir(filepath) and len(os.listdir(filepath)) > 0:
  File "/home/pi3ni0/.venv/dev/lib/python3.6/genericpath.py", line 42, in isdir
    st = os.stat(s)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType

It is because os.path.isdir cannot be applied to None argument.

Code sample

   checkpoint_callback = ModelCheckpoint(
        filepath=None,
    )

   trainer = pl.Trainer(
        checkpoint_callback=checkpoint_callback,
    )

   ...

Environment

* CUDA:
	- GPU:
		- GeForce GTX 1650 with Max-Q Design
	- available:         True
	- version:           10.2
* Packages:
	- numpy:             1.18.2
	- pyTorch_debug:     False
	- pyTorch_version:   1.5.0
	- pytorch-lightning: 0.7.5
	- tensorboard:       2.2.1
	- tqdm:              4.45.0
* System:
	- OS:                Linux
	- architecture:
		- 64bit
		- ELF
	- processor:         x86_64
@elkotito elkotito added bug Something isn't working help wanted Open to be worked on labels Apr 30, 2020
@olineumann
Copy link
Contributor

Duplicate issue #1660 #1535. Already fixed in PR #1654

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Open to be worked on
Projects
None yet
Development

No branches or pull requests

2 participants