
1-6 免费云端环境开通
以上是本地的安装,接着再来谈谈云端环境的开通,几乎Google GCP、AWS、Azure都提供机器学习的开发环境,这里介绍免费的Google云端环境Colaboratory,要有Gmail账号才能使用,它具备以下特点。
(1)免安装,只须开通:常用的框架均已预安装,包括TensorFlow、PyTorch。
(2)免费的GPU:使用GPU进行深度学习的模型训练会快上许多倍,Colaboratory提供NVIDIA Tesla K80 GPU显卡,含12GB内存。
(3)使用限制:Colaboratory在使用时会实时开通Docker container,只能连续使用12小时,逾时的话虚拟环境会被回收,虚拟机内的所有程序、数据一律会消失,要特别注意。
开通步骤如下。
(1)使用Google Chrome浏览器,进入云端硬盘(Google drive)接口。
(2)建立一个目录,例如“0”,并切换至该目录。

(3)在屏幕中间右击,单击“更多”>“关联更多应用”。

(4)在搜寻栏输入Colaboratory,找到后单击该App,单击“Connect”按钮即可开通。


(5)开通后,即可开始使用。可新增一个名为“Colaboratory”的文件。

注意,Google Colaboratory会自动开启虚拟环境,建立一个空白的Jupyter Notebook文件,文件名为ipynb,几乎所有的云端环境及大数据平台Databricks都以Notebook为主要使用接口。

或者直接双击Notebook文件,也可自动开启虚拟环境,进行编辑与执行。本地的Notebook文件也可上传至云端硬盘,单击即可使用,完全不用转换,非常方便。
若要支持GPU可设定运行环境使用GPU或TPU,TPU为Google发明的NPU。

Colaboratory相关操作,可参考官网说明[6]。
本书所附的范例程序,一律为Notebook文件。Notebook可以使用Markdown语法来撰写美观的说明,包括数学公式,并且程序也可以分格,实现单独执行,便于讲解,相关的用法可以参考Jupyter Notebook: An Introduction[7]。