OSError: [Errno 30] Read-only file system

Hi i’m having this error on kaggle when I try to use create_cnn

OSError Traceback (most recent call last)
in ()
----> 1 learn = create_cnn(data, models.resnet34, metrics=error_rate)

/opt/conda/lib/python3.6/site-packages/fastai/vision/learner.py in create_cnn(data, arch, cut, pretrained, lin_ftrs, ps, custom_head, split_on, bn_final, **kwargs)
57 head = custom_head or create_head(nf, data.c, lin_ftrs, ps=ps, bn_final=bn_final)
58 model = nn.Sequential(body, head)
—> 59 learn = Learner(data, model, **kwargs)
60 learn.split(ifnone(split_on,meta[‘split’]))
61 if pretrained: learn.freeze()

in init(self, data, model, opt_func, loss_func, metrics, true_wd, bn_wd, wd, train_bn, path, model_dir, callback_fns, callbacks, layer_groups)

/opt/conda/lib/python3.6/site-packages/fastai/basic_train.py in post_init(self)
138 “Setup path,metrics, callbacks and ensure model directory exists.”
139 self.path = Path(ifnone(self.path, self.data.path))
–> 140 (self.path/self.model_dir).mkdir(parents=True, exist_ok=True)
141 self.model = self.model.to(self.data.device)
142 self.loss_func = ifnone(self.loss_func, self.data.loss_func)

/opt/conda/lib/python3.6/pathlib.py in mkdir(self, mode, parents, exist_ok)
1244 self._raise_closed()
1245 try:
-> 1246 self._accessor.mkdir(self, mode)
1247 except FileNotFoundError:
1248 if not parents or self.parent == self:

/opt/conda/lib/python3.6/pathlib.py in wrapped(pathobj, *args)
385 @functools.wraps(strfunc)
386 def wrapped(pathobj, *args):
–> 387 return strfunc(str(pathobj), *args)
388 return staticmethod(wrapped)

OSError: [Errno 30] Read-only file system: ‘…/input/cell_images/cell_images/models’


add model_dir="/tmp/model/"


Thank you, it works! :smiley:

Sorry, I don’t quiet get what this mean. Can you explain a little bit?

Can you please direct how do we edit this on a kaggle kernel ?

Just do this:
 learn = create_cnn(data, models.resnet34, metrics= error_rate, model_dir="/tmp/model/")

Thank you. I worked now.

hey, can you explain, what does it mean?

You can’t write files in kaggle, it’s read only. So in you save the model file in a temporary folder ("/tmp/model/")

Thank you. It’s working fine for me.

Thanks for this advice - very helpful! I was able to run the PETs code from lesson 1 with this adjustment, however, I am still having trouble with the MNIST code.

I am going through the lesson1-pets notebook (2019 version) using PaperSpace Gradient and still get the same OS Error ([Errno 30] Read-only file system) when trying to call
path = untar_data(URLs.MNIST_SAMPLE)
as shown lesson1-pets. Interestingly, I do not get this error when calling
path = untar_data(URLs.PETS)

The difference between the two is that URLs.MNIST_SAMLE links to http://files.fast.ai/data/examples/mnist_sample while URLs.PETS links to https://s3.amazonaws.com/fast-ai-imageclas/oxford-iiit-pet’

Any advice highly appreciated!

Great advice, just wanted to point out that adding the model_dir=“X” parameter after the metrics parameter did not work for me.

This did work for me for some time, then it stopped working, though:
self.learner = cnn_learner(self.data, vision.models.resnet34, model_dir=,pretrained=True,metrics=vision.accuracy,path=pth.Path("."))

But this does work consistenly:
add the line os.environ[‘TORCH_HOME’] = , this changes the default path of download path models.

I get the same error when trying to
I am using lesson1-pets notebook.
What’s the cause and what’s the workaround. Any help will be appreciated.

I am using Paperspace.

Please Ignore I found the solution by changing learn.model_dir to desired path.

1 Like