在 Google Colab 上安装具有写入权限的 Google Drive

问题描述 投票:0回答:1

如何在 Google Colab 上安装我的 Google 云端硬盘并具有 write 访问权限?

那是因为当我的 AI 模型尝试更新 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'

顺便说一下,我已经将我的文件夹从 Google Drive 复制到了 Google Colab:

!git clone https://github.com/sicxu/Deep3DFaceRecon_pytorch.git
%cd Deep3DFaceRecon_pytorch

...

!mkdir checkpoints
!cp -r ../drive/MyDrive/Deep3D/facerecon_20230425 checkpoints/

...

更新

在 Google Colab 上,仅尝试在已安装的 Google Drive 中创建文件会引发错误:

!touch ./checkpoints/facerecon_20230425/test_opt.txt

日志:

touch: cannot touch './checkpoints/facerecon_20230425/test_opt.txt': Read-only file system
python google-drive-api google-colaboratory
1个回答
0
投票

共享文件夹

我在 Google Colab 上安装的 Google Drive 文件夹(我遇到了权限问题)与我共享。因此,我通过将其内容复制到我自己的新文件夹中,对 shared 文件夹进行了深层复制:

!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/

深度复制后,权限错误已解决。

© www.soinside.com 2019 - 2024. All rights reserved.