Hello,
In Lesson 10_nlp, in the Saving and Loading Models section, when I run
learn.save(‘1epoch’)
I get the following error:
OSError Traceback (most recent call last)
in
----> 1 learn.save(‘1epoch’)/opt/conda/envs/fastai/lib/python3.8/site-packages/fastai/learner.py in save(self, file, **kwargs)
282 @delegates(save_model)
283 def save(self, file, **kwargs):
→ 284 file = join_path_file(file, self.path/self.model_dir, ext=‘.pth’)
285 save_model(file, self.model, getattr(self,‘opt’,None), **kwargs)
286 return file/opt/conda/envs/fastai/lib/python3.8/site-packages/fastcore/xtras.py in join_path_file(file, path, ext)
177 “Returnpath/file
if file is a string or aPath
, file otherwise”
178 if not isinstance(file, (str, Path)): return file
→ 179 path.mkdir(parents=True, exist_ok=True)
180 return path/f’{file}{ext}’
181/opt/conda/envs/fastai/lib/python3.8/pathlib.py in mkdir(self, mode, parents, exist_ok)
1282 self._raise_closed()
1283 try:
→ 1284 self._accessor.mkdir(self, mode)
1285 except FileNotFoundError:
1286 if not parents or self.parent == self:OSError: [Errno 30] Read-only file system: ‘/storage/data/imdb/models’
So I did the following to change the saving directory:
learn.model_dir = Path(‘/fastbook/models/’)
learn.save(‘1epoch’)
That fixed the issue, but when I navigate the /fastbook/models/ directory, I cannot find 1epoch.pth, even though somehow I am able to load it afterwards with:
learn = learn.load(‘1epoch’)
So my questions are:
- Is there a better way to solve the initial issue above?
- How come I cannot find 1epoch.pth but the load() function can? What is going on here?