How can I mount my Google Drive on Google Colab with write access?
That's because I'm receiving an error when my AI model tries to update a file on Google Drive:
Traceback (most recent call last):
File "/content/Deep3DFaceRecon_pytorch/test.py", line 72, in <module>
opt = TestOptions().parse() # get test options
^^^^^^^^^^^^^^^^^^^^^
File "/content/Deep3DFaceRecon_pytorch/options/base_options.py", line 167, in parse
self.print_options(opt)
File "/content/Deep3DFaceRecon_pytorch/options/base_options.py", line 115, in print_options
with open(file_name, 'wt') as opt_file:
^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 30] Read-only file system: './checkpoints/facerecon_20230425/test_opt.txt'
By the way, I have already copied my folders from Google Drive to Google Colab:
!git clone https://github.com/sicxu/Deep3DFaceRecon_pytorch.git
%cd Deep3DFaceRecon_pytorch
...
!mkdir checkpoints
!cp -r ../drive/MyDrive/Deep3D/facerecon_20230425 checkpoints/
...
On Google Colab, just trying to create a file inside the mounted Google Drive throws an error:
!touch ./checkpoints/facerecon_20230425/test_opt.txt
Log:
touch: cannot touch './checkpoints/facerecon_20230425/test_opt.txt': Read-only file system
The Google Drive folder that I mounted on Google Colab, with which I had permission problems, was shared with me by someone else. So, I made a deep copy of the shared folder by copying its content to a new folder of my own:
!cp ../drive/MyDrive/Deep3D/facerecon_20230425--original/epoch_20.pth ../drive/MyDrive/Deep3D/facerecon_20230425/
!cp ../drive/MyDrive/Deep3D/facerecon_20230425--original/loss_log.txt ../drive/MyDrive/Deep3D/facerecon_20230425/
!cp ../drive/MyDrive/Deep3D/facerecon_20230425--original/train_opt.txt ../drive/MyDrive/Deep3D/facerecon_20230425/
After deep copying, the permission errors were resolved.
This post helped me: https://webapps.stackexchange.com/a/138917/154722