因為在學習machin learning 的時候想用google colaboratory的GPU可是不知道怎麼使用花了很多時間,這篇文章當作筆記。
首先是如何上傳File
# show upload dialog
from google.colab import files
uploaded = files.upload()
接著就可以選擇自己要上傳的file
接著是如何上傳整個folder
!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()
這是一開始要通過認證才可以上傳資料到google colab
然後要把要上傳的東西先上傳到google drive
接著就可以開始設定
輸入完下面的command之後按許可
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}
最後就可以來mount你的資料了!
!mkdir -p drive
!google-drive-ocamlfuse drive
!ls drive
不過雖然都是google的東西可是因為google colab不能連續使用12小時以上,每次都要重新設定感覺很麻煩
請先 登入 以發表留言。