Set dir for tmp.pth file

I read data for my model from shared database which I can’t write on.
Therefore, saving models and tmp folders/files is impossible for me.
I’ve managed changing models dir by doing

learn = create_cnn(data, models.resnet18, model_dir=''
                   ,metrics=fastai.metrics.accuracy)

How can I set the a path for tmp.pth?

tmp will be in model_dir, you should pass a Path object pointing to where you want it written.

1 Like

I came up with another problem related to this. I work in a distributed multigpu environment, where I can run multiple concurrent works on many machines.
All the machines share the filesystem so the processes conflict with the use of the same file tmp.pth.
Setting the path argument in the learner to a temp folder which is unique for each concurrent instance solved my problem

I suggest to use a unique name for tmp.pth, so that concurrent processes using the same file system do no conflict with each other