Frequently Asked Questions
The Basics
Colaboratory, or “Colab” for short, is a product from Google Research. Colab allows anybody to write and execute arbitrary python code through the browser, and is especially well suited to machine learning, data analysis and education. More technically, Colab is a hosted Jupyter notebook service that requires no setup to use, while providing access free of charge to computing resources including GPUs.
Yes. Colab is free of charge to use.
Colab resources are not guaranteed and not unlimited, and the usage limits sometimes fluctuate. This is necessary for Colab to be able to provide resources free of charge. For more details, see Resource Limits
Users who are interested in more reliable access to better resources may be interested in Colab Pro.
Resources in Colab are prioritized for interactive use cases. We prohibit actions associated with bulk compute, actions that negatively impact others, as well as actions associated with bypassing our policies. The following are disallowed from Colab runtimes:
- file hosting, media serving, or other web service offerings not related to interactive compute with Colab
- downloading torrents or engaging in peer-to-peer file-sharing
- using a remote desktop or SSH
- connecting to remote proxies
- mining cryptocurrency
- running denial-of-service attacks
- password cracking
- using multiple accounts to work around access or resource usage restrictions
- creating deepfakes
Additional restrictions exist for paid users here.
Jupyter is the open source project on which Colab is based. Colab allows you to use and share Jupyter notebooks with others without having to download, install, or run anything.
Using Colab
Colab notebooks are stored in Google Drive, or can be loaded from GitHub. Colab notebooks can be shared just as you would with Google Docs or Sheets. Simply click the Share button at the top right of any Colab notebook, or follow these Google Drive file sharing instructions.
If you choose to share a notebook, the full contents of your notebook (text, code, output, and comments) will be shared. You can omit code cell output from being saved or shared by using Edit > Notebook settings > Omit code cell output when saving this notebook. The virtual machine you’re using, including any custom files and libraries that you’ve setup, will not be shared. So it’s a good idea to include cells which install and load any custom libraries or files that your notebook needs.
Yes. Choose "Upload notebook" from the File menu.
You can search Colab notebooks using Google Drive. Clicking on the Colab logo at the top left of the notebook view will show all notebooks in Drive. You can also search for notebooks that you have opened recently using File > Open notebook.
Code is executed in a virtual machine private to your account. Virtual machines are deleted when idle for a while, and have a maximum lifetime enforced by the Colab service.
You can download any Colab notebook that you’ve created from Google Drive following these instructions, or from within Colab’s File menu. All Colab notebooks are stored in the open source Jupyter notebook format ( .ipynb).
Selecting Runtime > Disconnect and delete runtime to return all managed virtual machines assigned to you to their original state. This can be helpful in cases where a virtual machine has become unhealthy e.g. due to accidental overwrite of system files, or installation of incompatible software. Colab limits how often this can be done to prevent undue resource consumption. If an attempt fails, please try again later.
drive.mount()
sometimes fail saying "timed out", and why do I/O operations in drive.mount()
-mounted folders sometimes fail?Google Drive operations can time out when the number of files or subfolders in a folder grows too large. If thousands of items are directly contained in the top-level "My Drive" folder then mounting the drive will likely time out. Repeated attempts may eventually succeed as failed attempts cache partial state locally before timing out. If you encounter this problem, try moving files and folders directly contained in "My Drive" into sub-folders. A similar problem can occur when reading from other folders after a successful drive.mount()
. Accessing items in any folder containing many items can cause errors like OSError: [Errno 5] Input/output error
. Again, you can fix this problem by moving directly contained items into sub-folders.
Note that "deleting" files or subfolders by moving them to the Trash may not be enough; if that doesn't seem to help, make sure to also Empty your Trash.
Mounting Google Drive on Colab allows any code in your notebook to access any files in your Google Drive. We usually require that users manually grant this access every time they connect to a new runtime by adding a code cell to the notebook. This ensures that the user fully understands the permissions being granted to the notebook.
In some cases, we only require Google Drive authorization once, and automatically re-mount Google Drive during future sessions. To protect your files, we only allow this when a notebook passes multiple checks. For example, any notebooks which have been edited by another user do not automatically mount Google Drive.
Google Drive enforces various limits, including per-user and per-file operation count and bandwidth quotas. Exceeding these limits will trigger Input/output error
as above, and show a notification in the Colab UI. A typical cause is accessing a popular shared file, or accessing too many distinct files too quickly. Workarounds include:
- Copy the file using drive.google.com and don't share it widely so that other users don't use up its limits.
- Avoid making many small I/O reads, instead opting to copy data from Drive to the Colab VM in an archive format (e.g.
.zip
or.tar.gz
files) and unarchive the data locally on the VM instead of in the mounted Drive directory. - Wait a day for quota limits to reset.
Google Drive imposes a limit on how much data can be stored in it by each user. If Drive operations are failing withInput/output error
and a notification says storage quota has been exceeded, delete some files using drive.google.com and Empty your Trash to reclaim the space. It might take a little while for the reclaimed space to be available in Colab.
If you'd like to purchase more Drive space, visit Google Drive. Note that purchasing more space on Drive will not increase the amount of disk available on Colab VMs. Subscribing to Colab Pro will.
Resource Limits
In order to be able to offer computational resources free of charge, Colab needs to maintain the flexibility to adjust usage limits and hardware availability on the fly. Resources available in Colab vary over time to accommodate fluctuations in demand, as well as to accommodate overall growth and other factors.
Some users want to be able to do more in Colab than the resource limits allow. Colab Pro and Pro+ provide priority access to faster GPUs, longer running notebooks and more memory. Our long term goal is to continue providing a free of charge version of Colab, while also growing in a sustainable fashion to meet the needs of our users.
If you would like to have complete control over your resources in Colab, check out Colab GCP Marketplace VMs. Colab GCP Marketplace VMs allow you to specify the exact runtime resources to use and provide you with a persistent environment you can manage to your liking while still using the Colab UI.
Colab is able to provide resources free of charge in part by having dynamic usage limits that sometimes fluctuate, and by not providing guaranteed or unlimited resources. This means that overall usage limits as well as idle timeout periods, maximum VM lifetime, GPU types available, and other factors vary over time. Colab does not publish these limits, in part because they can (and sometimes do) vary quickly.
GPUs and TPUs are sometimes prioritized for users who use Colab interactively rather than for long-running computations, or for users who have recently used less resources in Colab. As a result, users who use Colab for long-running computations, or users who have recently used more resources in Colab, are more likely to run into usage limits and have their access to GPUs and TPUs temporarily restricted. Users interested in having higher and more stable usage limits may be interested in Colab Pro and Pro+. Users with high computational needs may be interested in using Colab’s UI with either a local runtime running on their own hardware or Colab GCP Marketplace VMs.
The types of GPUs that are available in Colab vary over time. This is necessary for Colab to be able to provide access to these resources free of charge. Users who are interested in more reliable access to Colab’s fastest GPUs may be interested in Colab Pro and Pro+. If you would like to use specific hardware in Colab, check out Colab GCP Marketplace VMs.
Note that using Colab for cryptocurrency mining is disallowed entirely, and may result in your account being restricted for use with Colab altogether.
Notebooks run by connecting to virtual machines that have maximum lifetimes that can be as much as 12 hours. Notebooks will also disconnect from VMs when left idle for too long. Maximum VM lifetime and idle timeout behavior may vary over time, or based on your usage. This is necessary for Colab to be able to offer computational resources free of charge. Users interested in longer VM lifetimes and more lenient idle timeout behaviors that don’t vary as much over time may be interested in Colab Pro and Pro+.
If you would like to manage the lifetime of your Colab VM, check out Colab GCP Marketplace VMs which provide you with a persistent environment you can manage to your liking.
The amount of memory available in Colab virtual machines varies over time (but is stable for the lifetime of the VM). (Adjusting memory over time allows us to continue to offer Colab free of charge.) You may sometimes be automatically assigned a VM with extra memory when Colab detects that you are likely to need it. Users interested in having more memory available to them in Colab, and more reliably, may be interested in Colab Pro and Pro+ or Colab GCP Marketplace VMs.
Resources in Colab are prioritized for users who have recently used less resources, in order to prevent the monopolization of limited resources by a small number of users. To get the most out of Colab, consider closing your Colab tabs when you are done with your work, and avoid opting for a GPU when it is not needed for your work. This will make it less likely that you will run into usage limits in Colab. Users interested in going beyond the resource limits in the free of charge version of Colab may be interested in Colab Pro and Pro+.
Colab offers optional accelerated compute environments, including GPU and TPU. Executing code in a GPU or TPU runtime does not automatically mean that the GPU or TPU is being utilized. To avoid hitting your GPU usage limits, we recommend switching to a standard runtime if you are not utilizing the GPU. Choose Runtime > Change Runtime Type and set Hardware Accelerator to None.
For examples of how to utilize GPU and TPU runtimes in Colab, see the Tensorflow With GPU and TPUs In Colab example notebooks.
Additional Questions
Colab works with most major browsers, and is most thoroughly tested with the latest versions of Chrome, Firefox and Safari.
In 2014 we worked with the Jupyter development team to release an early version of the tool. Since then Colab has continued to evolve, guided by internal usage.
Colab focuses on supporting Python and its ecosystem of third-party tools. We're aware that users are interested in support for other Jupyter kernels (eg R or Scala). We would like to support these, but don't yet have any ETA.
Open any Colab notebook. Then go to the Help menu and select ”Send feedback...”.
Colab uses HTML iframes and service workers hosted on separate origins in order to display rich outputs securely. Browsers require enabling third-party cookies to use the service workers within iframes. An alternative to enabling third-party cookies for all sites is to allow the following hostname in your browser settings: googleusercontent.com.
Colab uses a generic monospace font for the editor. You can configure what font family is used for monospace in most modern browsers. Here's a few common ones:
- In Firefox, follow the steps provided in the Firefox support documents to configure the "Monospace" font.
- In Chrome, navigate to "chrome://settings/fonts" and modify the section labeled "Fixed-width font".
Python 2 is no longer supported in Colab. For information on migrating your code from Python 2 to Python 3, see Porting Python 2 Code to Python 3.
There is an FAQ for Colab Pro and Pro+ on the sign-up page.
Information for Colab Pro and Pro+, including pricing and how upgrades are handled, can be found at the Colab Pro and Pro+ sign-up page.
Access to Colab for Workspace users is controlled by the Workspace on/off control accessible to your organization's administrator.
Workspace for Education organizations are required to obtain parental consent for students' (under the age of 18) use of Additional Services with their Google Workspace for Education account. For more information, please read our Help Center article “Communicating with Parents and Guardians about Google Workspace for Education”. Note that Google accounts for children under the age of 13 are not supported.