在Google Cloud Platform谷歌云上配置完成之后,咱們就擁有交互式編程筆記「JupyterNotebook」環(huán)境,配有GPU硬件圖形加速器,以調動充分的「算力」,來學習fast.ai的深度學習(煉丹)技術。
傳送門:fastai官方GCP服務配置教程https://course.fast.ai/start_gcp.html
07.09更新:國內朋友可以試試->易學智能https://course.fast.ai/start_easyaiforum.html
步驟1:創(chuàng)建你的賬戶
前往官網https://cloud.google.com/,創(chuàng)建新賬戶。
價格與性能
·潛在的坑:盡管有300美元的初始額度,但我們需要開啟賬單(Billing)功能,綁定信用卡或借記卡,等候幾個工作日之后激活它。
Potential roadblock:Even though GCP provides a$300 initial credit,you must enable billing to use it.You can put a credit card or a bank account but the latter will take several days for the activation.
·比如,結算的坑:你在GoogleClound里運行虛擬鏡像的項目,需要連接至你的賬單賬號。導航到billing dashboard,點擊「...」菜單,選擇「更改賬單賬號」。
The project on which you are going to run the image needs to be linked with your billing account.For this navigate to the billing dashboard,click the‘…’menu and choose‘change billing account’.
步驟2:安裝Google命令行工具
筆者使用的是macOS系統(tǒng),進行了如下操作命令:
與報錯不期而遇:連接Google的SDK服務失敗,端口443,操作超時
查看官網文檔
https://cloud.google.com/sdk/docs/quickstart-macos
在準備工作中的第二條,赫然寫著
確保您的系統(tǒng)上安裝了Python 2.7:
python-V
系統(tǒng)反饋,我當前使用的是Python3.6.8版本使用pyenv模塊,創(chuàng)建一個python2.7.x的虛擬環(huán)境?
警告:Python2.7要在2020年1月時被“廢黜”。
激活所創(chuàng)建的虛擬環(huán)境
提示是否繼續(xù)時,輸入y
https://accounts.google.com/o/oauth2/auth?redirect_uri=http%3A%2F%2Flocalhost%3A8085%2F&prompt=select_account&response_type=code&client_id=32555940559.apps.googleusercontent.com&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth&access_type=offline
這時,瀏覽器會自動打開授權頁面,請授權你的谷歌云平臺賬號。
Project IDs must be 6-30 characters(lowercase ASCII,digits,or
hyphens)in length and start with a lowercase letter.fastai
WARNING:Project creation failed:HttpError accessing<https://cloudresourcemanager.googleapis.com/v1/projects?alt=json>:response:<{'status':'409','content-length':'119','x-xss-protection':'1;mode=block','x-content-type-options':'nosniff','transfer-encoding':'chunked','vary':'Origin,X-Origin,Referer','server':'ESF','-content-encoding':'gzip','cache-control':'private','date':'Sun,27 Jan 2019 16:39:11 GMT','x-frame-options':'SAMEORIGIN','alt-svc':'quic=":443";ma=2592000;v="44,43,39"','content-type':'application/json;charset=UTF-8'}>,content<{
"error":{
"code":409,
"message":"Requested entity already exists",
"status":"ALREADY_EXISTS"
}
}
>
Please make sure to create the project [fastai] using
$gcloud projects create fastai
or change to another project using
$gcloud config set project<PROJECT ID>
https://cloud.google.com/compute/docs/gcloud-compute
至此,谷歌云GCP的SDK配置完畢。
步驟3:創(chuàng)建一個實例(Instance)
輸入各種配置指令,比如「IMAGE_FAMILY(鏡像組合)」->"pytorch-latest-gpu",「ZONE」->"us-west1-b"等等。最新操作步驟,請移步查閱https://course.fast.ai/start_gcp.html
Enabling service compute.googleapis.com on project 191131005934...
ERROR:(gcloud.compute.instances.create)FAILED_PRECONDITION:Operation does not satisfy the following requirements:billing-enabled{Billing must be enabled for activation of service''in project'fastai-v3-229916'to proceed.,https://console.developers.google.com/project/fastai-v3-229916/settings}
設置了結算賬戶之后,
image.png
image.png
步驟3:創(chuàng)建你的示例
再次輸入CLI命令行代碼,創(chuàng)建示例
功夫不負有心人,創(chuàng)建成功。
一大串的命令行英文,非常嚇人。
查看GPU,型號是:Tesla P4
步驟4:接入fast.ai材料,更新工具包
回到控制臺,
adi0229(adi0229)~
$pyenv activate google-cli
pyenv-virtualenv:prompt changing will be removed from future release.configure`export PYENV_VIRTUALENV_DISABLE_PROMPT=1'to simulate the behavior.
(google-cli)adi0229(adi0229)~
步驟5:停止實例運行
參考資料
https://www.jianshu.com/p/7d720393fea3
https://course.fast.ai/update_gcp.html
https://course.fast.ai/start_gcp.html