Google Colab教程

参考Github仓库
Colab is a Google’s free cloud service which will let you run your deep learning or machine learning models in cloud.

Creating New Colab Notebook

  • open your Google Drive
  • create a new notebook via Right click -> More
    ->Colaboratory

In mainland china, you may need to using proxy:

Brook Tools :
Cofigeration:
Server IP :
Server Port:
Server Pwd:
Server Protocol: Brook
File Dir: manual select Brook.exe dir
And then click run:
Test:
SOCKS5 :127.0.0.1:1080

GPU Setting:

Edit ->Notebook settings or Runtime -> Change runtime type and select GPU as Hardware accelerator

RAM Info

!cat /proc/meminfo

CPU Info

!cat /proc/cpuinfo

Install Libraries

# !pip install or !apt-get install

!pip3 install tensorflow [==1.8]
!pip3 install keras
!pip3 install torch [ torchvision]
!apt-get install python-numpy python-scipy

Pip3 and pip distinctions

Using ‘pip3’ means install package for python 3.x
Or you can using ‘pip’ to install package for python 2.x
downloading lib dir : python3.x/site-packages or python2.x/site-packages

When python3 or python somefile.py, you can only using python3.x or python 2.x packages, so as to avoid lib conflicts.

Play in Kaggle

In Jupyter Notebook or Google Colab, we can using Kaggle API make submittions on Kaggle competions
Notices: ONLY for kaggle API version > 1.5.0 and ONLY support Python 3.

!pip install kaggle --upgrade

Kaggle-API

Cloning Github Repo to Google Colab

!git clone https://github.com/xxxrepos

Mount your Google Drive

from google.colab import drive
drive.mount('/content/drive/')

Check your Folder Data

!ls Drive/test

Upload code from your system

from google.colab import files
uploaded = files.upload()

Make zip file of your Data

from google.colab import files
import zipfile
import sys
foldername = 'your folder or filename'
zipfile.ZipFile('Drive/'+foldername +'.zip', 'w', zipfile.ZIP_DEFLATED)

Downloading the data from the colab

from google.colab import files
files.download('Drive/test.zip')

Summary

个人总结一下,其实在Google Colab 的诸多操作就是Linux 命令,它使用编辑器的就是Jupyter Notebook,不熟悉JN的同学希望每行都练一练以及多熟悉熟悉Linux命令行。

你可能感兴趣的:(python)