Using lr_find() gives me an unexpected OSError

I’m working on doing Pneumonia detection using Chest X-rays Image data found in Kaggle. But I’m having trouble finding the best learning rate when I execute the line


I get the below error;

OSError: [Errno 30] Read-only file system: '/kaggle/input/chest-xray-pneumonia/chest_xray/models'

To give you some context about my data, here is how my directory is organized

The weird thing is that when I try to find the best lr when using a fastai available dataset like the PETS one, it works perfectly fine and finds the best lr.

And by the way, I’m using fastai version 2.7.12 which is the latest version

So kindly help me fix this error.


In Kaggle kernels, the “/kaggle/input” directory is read-only, so you need to use “/kaggle/working” directory which is read-write.
It can be done if you give the “model_dir” parameter for your Learner (the default is model_dir=‘models’)
Example: vision_learner(dls, resnet34, model_dir=‘/kaggle/working/models’)

You can see vision_learner’s parameters here (but it works with other learners too):

Other older similar cases:

1 Like

Thank you @AmorfEvo your solution has really worked for me. The use of model_dir='/kaggle/working/models' works and fixes the issue.

Thanks a lot

1 Like