[FreeGPU]colab用法详解 妈妈再也不用担心我们买不起显卡租不起服务器啦

colaboratory = Jupyter + GPU

Following these steps, you are able to enjoy GPU service for FREE.

1. Register a google account

2. Login to Google Drive

3. New folder(take a name whether you like) 

[FreeGPU]colab用法详解 妈妈再也不用担心我们买不起显卡租不起服务器啦_第1张图片

4. Right-click the folder-Open with-Connect more apps  


[FreeGPU]colab用法详解 妈妈再也不用担心我们买不起显卡租不起服务器啦_第2张图片

5. find "Colaboratory" and connect

[FreeGPU]colab用法详解 妈妈再也不用担心我们买不起显卡租不起服务器啦_第3张图片

6. create ipynb under the new folder

[FreeGPU]colab用法详解 妈妈再也不用担心我们买不起显卡租不起服务器啦_第4张图片

7. Edit-Notebook settings

 [FreeGPU]colab用法详解 妈妈再也不用担心我们买不起显卡租不起服务器啦_第5张图片

(This style really recalls jupyter, but jupyter don't have a GPU...)

8. select GPU

[FreeGPU]colab用法详解 妈妈再也不用担心我们买不起显卡租不起服务器啦_第6张图片

Tips: Remember these steps. Each time you establish a new py file, you need to set the GPU again.

9. Test GPU?

 [FreeGPU]colab用法详解 妈妈再也不用担心我们买不起显卡租不起服务器啦_第7张图片

Further, I am curious about which type of GPU google offered.

[FreeGPU]colab用法详解 妈妈再也不用担心我们买不起显卡租不起服务器啦_第8张图片

Tesla K80 ON Amazon-$2800.

[FreeGPU]colab用法详解 妈妈再也不用担心我们买不起显卡租不起服务器啦_第9张图片

10. Now you can enjoy a $2800-GPU for FREE.

Tips: As you know, you need to pip/conda many computation packages.

11. Authorized to use these packages.

run these codes in colab:

!apt-get install -y -qq software-properties-common python-software-properties module-init-tools
!add-apt-repository -y ppa:alessandro-strada/ppa 2>&1 > /dev/null
!apt-get update -qq 2>&1 > /dev/null
!apt-get -y install -qq google-drive-ocamlfuse fuse
from google.colab import auth
auth.authenticate_user()
from oauth2client.client import GoogleCredentials
creds = GoogleCredentials.get_application_default()
import getpass
!google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} < /dev/null 2>&1 | grep URL
vcode = getpass.getpass()
!echo {vcode} | google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret}
click the link and get the verification code.

[FreeGPU]colab用法详解 妈妈再也不用担心我们买不起显卡租不起服务器啦_第10张图片
now access successfully

[FreeGPU]colab用法详解 妈妈再也不用担心我们买不起显卡租不起服务器啦_第11张图片

Next part is my personal demands. If any question, you can turn help to StackOverflow-google-colaboratory

12. Install Xgboost to compete with kaggle players. 

!pip install -q xgboost==0.4a30 (this is a lower edition)
!apt-get -qq install -y graphviz && pip install -q pydot

Xgboost works perfectly

[FreeGPU]colab用法详解 妈妈再也不用担心我们买不起显卡租不起服务器啦_第12张图片13. Install pytorch package.(I think the kernel is tensorflow)

!pip install -q http://download.pytorch.org/whl/{accelerator}/torch-0.3.0.post4-{platform}-linux_x86_64.whl torchvision

Test the famous dataset-mnist.

[FreeGPU]colab用法详解 妈妈再也不用担心我们买不起显卡租不起服务器啦_第13张图片

I meet some File Path problem.In colab, we'd better use the GetFullPath like "drive/foldername/filename".

14. We easily get access to Stack Overflow to modify our codes.

[FreeGPU]colab用法详解 妈妈再也不用担心我们买不起显卡租不起服务器啦_第14张图片

15.Through these installs, apparently, the packages are stored in our google cloud. Files the same as packages are saved to the cloud. So we just need a computer to transfer these files to cloud and put down our codes on colab.Then, colab help to read the data and use 2800$-GPU to run our neural network program.

I am a newcomer to colab. Now pycharm seems out of date compared with colab. Especially, when we are not easy to get a GPU. And why not share this ide with our friends? There remain many great usages in this fantastic plug-in unit. If there are any errors, please correct me.

你可能感兴趣的:(machine,learning,deep,learning)