在Google Cloud Platform谷歌云上配置完成之后,咱們就擁有交互式編程筆記「JupyterNotebook」環(huán)境,配有GPU硬件圖形加速器,以調(diào)動(dòng)充分的「算力」,來學(xué)習(xí)fast.ai的深度學(xué)習(xí)(煉丹)技術(shù)。
傳送門:fastai官方GCP服務(wù)配置教程https://course.fast.ai/start_gcp.html
07.09更新:國內(nèi)朋友可以試試->易學(xué)智能https://course.fast.ai/start_easyaiforum.html
步驟1:創(chuàng)建你的賬戶
前往官網(wǎng)https://cloud.google.com/,創(chuàng)建新賬戶。
價(jià)格與性能
·潛在的坑:盡管有300美元的初始額度,但我們需要開啟賬單(Billing)功能,綁定信用卡或借記卡,等候幾個(gè)工作日之后激活它。
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.
·比如,結(jié)算的坑:你在GoogleClound里運(yùn)行虛擬鏡像的項(xiàng)目,需要連接至你的賬單賬號(hào)。導(dǎo)航到billing dashboard,點(diǎn)擊「...」菜單,選擇「更改賬單賬號(hào)」。
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),進(jìn)行了如下操作命令:
與報(bào)錯(cuò)不期而遇:連接Google的SDK服務(wù)失敗,端口443,操作超時(shí)
查看官網(wǎng)文檔
https://cloud.google.com/sdk/docs/quickstart-macos
在準(zhǔn)備工作中的第二條,赫然寫著
確保您的系統(tǒng)上安裝了Python 2.7:
python-V
系統(tǒng)反饋,我當(dāng)前使用的是Python3.6.8版本使用pyenv模塊,創(chuàng)建一個(gè)python2.7.x的虛擬環(huán)境?
警告:Python2.7要在2020年1月時(shí)被“廢黜”。
激活所創(chuàng)建的虛擬環(huán)境
提示是否繼續(xù)時(shí),輸入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
這時(shí),瀏覽器會(huì)自動(dòng)打開授權(quán)頁面,請授權(quán)你的谷歌云平臺(tái)賬號(hào)。
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)建一個(gè)實(shí)例(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}
設(shè)置了結(jié)算賬戶之后,
image.png
image.png
步驟3:創(chuàng)建你的示例
再次輸入CLI命令行代碼,創(chuàng)建示例
功夫不負(fù)有心人,創(chuàng)建成功。
一大串的命令行英文,非常嚇人。
查看GPU,型號(hào)是:Tesla P4
步驟4:接入fast.ai材料,更新工具包
回到控制臺(tái),
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:停止實(shí)例運(yùn)行
參考資料
https://www.jianshu.com/p/7d720393fea3
https://course.fast.ai/update_gcp.html
https://course.fast.ai/start_gcp.html