Torch.save: RuntimeError: Parent directory does not exist

Hi, I’m trying to save my trained model on Google Drive via Google Colab but I get this error although the directory exists in my Google drive:

/content/drive/MyDrive/spawn-main

MMNet Training Script

2023-12-10 18:12:47.276362: E tensorflow/compiler/xla/stream_executor/cuda/cuda_dnn.cc:9342] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2023-12-10 18:12:47.276416: E tensorflow/compiler/xla/stream_executor/cuda/cuda_fft.cc:609] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2023-12-10 18:12:47.276453: E tensorflow/compiler/xla/stream_executor/cuda/cuda_blas.cc:1518] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2023-12-10 18:12:47.284903: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX512F FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-12-10 18:12:48.335569: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
Training model R5_MMNet_SUPERV-NYU-depth+rgb+normals_da
train: Epoch 1/80 Loss: 1.9362 MIoU: 0.1180: 100% 199/199 [04:19<00:00, 1.30s/it]
valid: Epoch 1/80 Loss: 1.7581 MIoU: 0.1275: 100% 164/164 [04:16<00:00, 1.57s/it]
mIoU improved from 0.00000 to 0.12751
Traceback (most recent call last):
File “/content/drive/MyDrive/spawn-main/spawn_train.py”, line 262, in
main()
File “/content/drive/MyDrive/spawn-main/spawn_train.py”, line 258, in main
train()
File “/content/drive/MyDrive/spawn-main/spawn_train.py”, line 250, in train
model = train_model(model, dev, dataloaders, unsup_dataloader, criterion, opt,
File “/content/drive/MyDrive/spawn-main/utils/semi_sup_train.py”, line 304, in train_model
torch.save(model.state_dict(), “/content/drive/MyDrive/spawn-main/weights/{}EPOCH{}”.format(model_name, epoch))
File “/usr/local/lib/python3.10/dist-packages/torch/serialization.py”, line 618, in save
with _open_zipfile_writer(f) as opened_zipfile:
File “/usr/local/lib/python3.10/dist-packages/torch/serialization.py”, line 492, in _open_zipfile_writer
return container(name_or_buffer)
File “/usr/local/lib/python3.10/dist-packages/torch/serialization.py”, line 463, in init
super().init(torch._C.PyTorchFileWriter(self.name))
RuntimeError: Parent directory /content/drive/MyDrive/spawn-main/weights does not exist.

I’d appreciate it if you could help me.

1 Like