How to mount my Google Drive in Colab?


What is Colab? Colab Notebooks?


Colaboratory is a Google research project created to help disseminate machine learning education and research. It's a Jupyter notebook environment that requires no setup to use and runs entirely in the cloud. 

How long can I use it continuously?
Google Colab notebooks have an idle timeout of 90 minutes and absolute timeout of 12 hours. This means, if user does not interact with his Google Colab notebook for more than 90 minutes, its instance is automatically terminated.




The following example shows how to mount your Google Drive to Colab and run your Python code.

from google.colab import drive

# mount your Google Drive
drive.mount("/content/gdrive") 

# set your root path for the project
root_path = "gdrive/My Drive/app/"

# load and plot dataset
def parser(x):
  return datetime.strptime("190"+x, "%Y-%m")

series = read_csv(root_path+"/data/shampoo.csv", 
                  header=0, 
                  parse_dates=[0], 
                  index_col=0,
                  squeeze=True,
                  date_parser=parser)

# summarize the first few rows
print(series.head())
series.plot()
plt.show()


Can I use GPU?
As of October 13, 2018, Google Colab provides a single 12GB NVIDIA Tesla K80 GPU that can be used up to 12 hours continuously. Recently, Colab also started offering free TPU. You can set up your hardware by selecting the menu:

$ Runtime => Change Runtime Type => Change "Hardware accelerator" to GPU or TPU


Other useful tips 
  • Remeber to save the notebook regularly (Ctrl + s)
  • Use Markdown language (e.g., ## and ###) can generate the Table of Contents automatically
  • You can check the resource (i.e., RAM, Disk) usage and session information in Manage Sessions, and even Terminate your session 



No comments:

Post a Comment