SageMaker endpoint load_learner read-only file system

Hi, I’ve created a unet learner to train on SageMaker with the arguments path=Path('/opt/ml'), model_dir='model'. Since export places the pkl file into path, I export as learn.export(fname=Path('model/export.pkl')). This results in my .pth files and .pkl file all being saved into /opt/ml/model/.

I then try to use load_learner in my endpoint serve script, but I get the error: OSError: [Errno 30] Read-only file system: '/opt/ml/model/model'. It looks like load_learner is trying to mkdir the model_dir again, like os.makedirs(path/model_dir/model_dir)?

Is there some way I can change this behavior?

Edit: solved, just needed to do load_learner(Path('/opt/ml/'), fname=Path('model/export.pkl'))


is there any priorty line of code ? which one is first ?

Sorry, not sure if I understand your question.

ı handled it. What worls this path ‘/opt/ml/’ ?

It’s a specific path used by AWS SageMaker instances