# Google Colab Note ## Example - https://medium.com/better-programming/one-stop-guide-to-google-colab-d67c94d30516 ### Map your Google Drive To run or import Python files. ```python= from google.colab import drive drive.mount('/content/gdrive') ``` ![image alt](https://miro.medium.com/max/900/1*sQhNUw_YwtFgMowLrCv3Gg.jpeg) ### Creatig Folders ```python= !mkdir folder-name ``` ### Install Libraries Though most of the libraries come pre-installed, some of the not-so-common ones can be installed with: ```python= !pip install torch ``` ### Cloning GitHub repository in Google Colab ```python= !git clone <github repo URL> ``` ### Changing working directory ```python= %cd new-folder ``` ### Running TensorBoard in Google Colab ```python= LOG_DIR = 'tb_logs' !wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip !unzip ngrok-stable-linux-amd64.zip import os if not os.path.exists(LOG_DIR): os.makedirs(LOG_DIR) get_ipython().system_raw('tensorboard --logdir {} --host 0.0.0.0 --port 6006 &'.format(LOG_DIR)) get_ipython().system_new('./ngrok http 6006 &') !curl -s http://localhost:4040/api/tunnels | python3 -c \"import sys, json; print(json.load(sys.stdin)['tunnels'][0]['public_url'])" ``` ### Using a free GPU Runtime Select "Runtime" -> "Change runtime type" -> set "Hardware accelerator" to GPU (the default is **CPU**) ![image alt](https://miro.medium.com/max/463/1*7du2-qMemro5nvxnePNuKQ.png) ### Download data from web ```python= !wget url ``` ### Running a Python script ```python= !python run.py ``` ### Restart Google Colab ```python= !kill -9 -1 ```