巧妙运用GoogleDrive谷歌云盘GPU免费训练

巧妙运用GoogleDrive谷歌云盘GPU免费训练

Tips 1 登陆GoogleDrive创建Colaboratory

转到网站https://drive.google.com,创建一个文件夹,你随意,在文件夹内创建一个Colaboratory notebook,右键,新建-更多-Colaboratory
注意:如果找不到Colaboratory的话,点“关联更多应用”,找到Colaboratory再下载后继续上面操作
图1

在这里插入图片描述

Tips 2 配置Colaboratory

双击打开笔记本,到如下界面,点击修改-笔记本设置,修改为python3与GPU,保存即可。
在这里插入图片描述

在这里插入图片描述

Tips 3 授权

到笔记本正文,复制以下代码运行,进行授权。

!apt-get install -y -qq software-properties-common python-software-properties module-init-tools
!add-apt-repository -y ppa:alessandro-strada/ppa 2>&1 > /dev/null
!apt-get update -qq 2>&1 > /dev/null
!apt-get -y install -qq google-drive-ocamlfuse fuse
from google.colab import auth
auth.authenticate_user()
from oauth2client.client import GoogleCredentials
creds = GoogleCredentials.get_application_default()
import getpass
!google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} < /dev/null 2>&1 | grep URL
vcode = getpass.getpass()
!echo {vcode} | google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

执行会出现下面界面,点击链接登陆会有一个验证码,填到这里即可。
在这里插入图片描述

Tips 4 跑代码

挂载云盘中的文件

!mkdir -p drive
!google-drive-ocamlfuse drive
  • 1
  • 2

这样你把文件传到云盘就可以啦,剩下的就是常规指令。
譬如:
安装某包

!pip install -q keras
  • 1

运行某文件

!python 1.py
  • 1

执行python指令

import tensorflow as tf

发表评论

邮箱地址不会被公开。 必填项已用*标注

沪ICP备2020036959号-10