Use rclone on google colab

I'm new to google colab and rclone, and I can't seem to find any tutorial on how to clone rclone into google colab and start using rclone with command !rclone.
I tried to clone it with command: ! git clone https://github.com/rclone/rclone.git
and it said all done, but then when I type !rclone it returns: /bin/bash: rclone: command not found

Can you please help me on how to use rclone on my google colab? thanks.

1 Like

Check out:

https://rclone.org/install/

I've often used rclone on Colab because the default drive connector has a timeout problem.

Create a new code cell, paste the installation command and execute it.

! curl https://rclone.org/install.sh | sudo bash

Read the documentation https://rclone.org/docs/ to understand rclone - how the config system works, etc.

If you have an existing rclone config, you can write the config file directly into a cell:

!mkdir /root/.config/rclone/
config = """
RCLONE_ENCRYPT_V0:
8nKbmBes1LhfViVPk1b4rfmXeDLwjOgFRCQSKQJARLt43kY6hyutSoKXZ+YelRSlNGStD1wNmA3scjoiDgdYEDpdx/DQsLUzytbwsOc3cbnZyWaywPvSFqkG
"""
with open('/root/.config/rclone/rclone.conf', 'w') as file:
  file.write(config)

Afterwards, you can call rclone like any other native command:

!rclone copy a b

A few things from experience:

  • Keep an eye on the traffic - I've heard from people that had their account banned for excessive colab usage. Personally, I have only received temporary GPU bans though, so who knows.
  • If you want persistence, do not use rclone mount - instead, schedule repeated runs of rclone copy, usually with much better performance.
  • Colab resets and recycles your docker instance when not in use (or >12h). If you save your file system at the end of your notebook, you can restore it in the beginning of your notebook the next time you use it.
5 Likes

Thank you so much, it worked.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.