Google Colab: Difference between revisions

From David's Wiki
No edit summary
 
Line 27: Line 27:
[https://stackoverflow.com/questions/54595285/how-to-use-r-with-google-colaboratory how to use r with google colab]<br>
[https://stackoverflow.com/questions/54595285/how-to-use-r-with-google-colaboratory how to use r with google colab]<br>
There are two ways to do this:
There are two ways to do this:
* Use <code>%load_ext rpy2.ipython</code> to enable R and add <code>%%R<code> to each R cell.
* Use <code>%load_ext rpy2.ipython</code> to enable R and add <code>%%R</code> to each R cell.
* Use [https://colab.to/r colab.to/r]
* Use [https://colab.to/r colab.to/r]


==Colab Pro==
==Colab Pro==

Latest revision as of 15:57, 2 September 2021

Google Colab is a free online Jupyter notebook you can access for small ML training exercises.
It supports Python and R.


Google Drive

Colab supports mounting Google Drive.
However, files are cached locally on the VM which only has ~100GB.
This means you cannot directly write (e.g. via curl) files over 100GB to your Google Drive folder.

There are some tricks you can try though:

curl
  • Run curl -r 0-4999999999 [url] -o part1 to download ~50GB your Google Drive
  • Wait ~10 minutes for the cache to clear and files to copy over
  • Do curl -r 5000000000-9999999999 [url] -o part2
  • Repeat until you have the whole >50GB file
  • .

Limitations

  • You can't create non-empty files in a folder that is shared with you.
  • Colab struggles copying large files and handing folders with lots of file in Google Drive.

Workarounds

R Runtime

how to use r with google colab
There are two ways to do this:

  • Use %load_ext rpy2.ipython to enable R and add %%R to each R cell.
  • Use colab.to/r

Colab Pro

Colab Pro

Claims faster GPUs, longer runtimes, and more memory.
However nothing is guaranteed and VMs are still preemptible.
Runtimes are limited to 24 hours as opposed to 12 hours for free users.