Getting error on Kaggle kernel when using cnn_learner function

When I ran the command learn.lr_find the kaggle kernel throughs an error OSError: [Errno 30] Read-only file system: ‘…/input/purge-tmp.pkl.

So I saw the forum, there it was mentioned to update the fastai library and add the argument model_dir in the function cnn_learner. I follow the steps but still I am getting the following error:

TypeError: __init__() got an unexpected keyword argument 'modeldir'

I am using ‘1.0.61’ version of fastai.

Do not add it as argument. Set it after making an instance of cnn_learner.
Like this:
learn = cnn_learner(data, models.resnet50)
learn.model_dir = “/kaggle/working”

2 Likes

@moein That worked. Thanks.

But I still need to tell the learner to go up a directory. Like I am getting the error Can't write to '../input/humpback-whale-identification/../kaggle/working'. What should I do?

Like for general Python, we can write !cd .. but that is not working for the learner

could you clarify what do you want to do?
you shouldn’t give it the kaggle input path, because that’s not writable.
just put the model_dir equal to “/kaggle/working”

@moein Thanks you, the issue has been resolved.

The path to learner which was been given by me was ../ouput/kaggle/working but it was picking up the rest of the path from image bunch. Below are my old code:

src = (ImageList.from_csv(’…/input/humpback-whale-identification/’,
‘train.csv’, folder = ‘train’).split_by_rand_pct(0.2).label_from_df(label_delim=’ '))

learn.model_dir="…/output/kaggle/working"

So, I just edited the path, and the new code is:

learn.model_dir="…/kaggle/working"

1 Like