前言
Google Colab,全名Colaboratory,是由谷歌提供的免费的云平台,可以使用keras、tensorflow、pytorch等框架进行深度学习。
可以白嫖性能强劲的GPU
提供Tesla P4、T4、P100等
tips:需要科学上网与Google账号
新建Google Colaboratory文件
登录Google drive
新建colab对应的文件
选择GPU
也可以选择TPU(一般需要额外的环境)
装载Google drive
配置环境
查看分配的显卡
!nvidia-smi
这里的环境配置以pytorch为例
numpy、opencv等库colab自带
# install dependencies: (use cu100 because colab is on CUDA 10.0)
!pip install -U torch==1.4+cu100 torchvision==0.5+cu100 -f https://download.pytorch.org/whl/torch_stable.html
环境配置完成,可以开始训练了!
可以用shutil将Google drive上的数据集等文件拷贝到分配的机器上
例子:
import os, shutil
shutil.copyfile('/content/drive/My Drive/coco.zip', 'coco.zip')