Learn.save nbs 01

Hi there,

I would like to save the learner for text classification shown in the notebook #1

but I get the error saying “OSError: [Errno 30] Read-only file system: ‘/storage/data/imdb/models’”

I thought that if I ran this : " ! chmod a+rwx /storage/data/imdb/models" it will make it work, but it doesn’t.

Any suggestion on how to fix it?

here is a screenshot of my try

1 Like

It says no such file or directory

Thanks Joedockrill, and how could I change that? my intention is to save de learner and after that export it using export.

I tried to change path to ‘storage’ and it does not work neither

You can’t chmod a directory which doesn’t exist. It’s failing inside pathlib where it’s trying to create the dir. You need to see how high up it really exists (does /storage/data/imdb exist? How about /storage/data?) and try chmoding that.

Are you using paperspace? You can also check and create directories manually.

You could also change the path of the learner (learn.path) to save the model in some other directory.

Btw, I don’t think you need to save a learner before using learn.export. For more details see the docs: https://docs.fast.ai/learner#Learner.export

You can also specify a full path to somewhere you definitely have permission for. On Colab I always save and export straight to Google drive.

1 Like

@stefa-ai yes, I am using paperspace. belive the problem is that I am trying to export the learner to the wrong directoty, and I do not know how to change it. How could I change the Path in paperspace, look what I have"

Maybe try this:

path = Path('/your_directory')
learn.path = path
1 Like

@joedockrill Sorry fro the delay iun replying, I check and in fact the directory does exist. I am in paperspace and from the terminal I saw it

If I write

path = Path(’/notebooks’)
learn.path = path

will it work?

I don’t know the setup on paperspace (I use Colab) but it sounds like it should. Try it.

import fastai
from fastai2.text.all import *
from utils import *

path = Path('/notebooks')

learn = load_learner(path/'model_pred.pkl', cpu=True)
learn.fine_tune(3, 1e-2)
learn.predict('nice movie')

Yes It worked. Thanks @joedockrill and thanks @stefan-ai