Useful recipes for your general colab workflow (not restricted to fastai).
!nvidia-smi
For a stable version:
!pip install -q fastai2
For a bleeding edge install:
!pip install -q git+git://github.com/fastai/fastcore.git
!pip install -q git+git://github.com/fastai/fastai2.git
If you are often switching from local to colab:
try:
import fastai2
except ImportError:
!pip install -q git+git://github.com/fastai/fastcore.git
!pip install -q git+git://github.com/fastai/fastai2.git
We are just using Path
from fastai here, if you don't want to install fastai you can instead do from pathlib import Path
.
from fastai2.basics import *
from google.colab import drive
drive.mount('/content/gdrive', force_remount=True)
root_dir = Path('/content/gdrive/My Drive/')
If you are constantly switching between colab and your local machine:
try:
from google.colab import drive
drive.mount('/content/gdrive', force_remount=True)
root_dir = Path('/content/gdrive/My Drive/dl')
except ImportError:
root_dir = Path.home()/'dl'
root_dir.mkdir(exist_ok=True)
function ClickConnect(){
console.log("Clicked on connect button");
document.querySelector("colab-connect-button").click()
}
setInterval(ClickConnect,60000)
from google.colab import files
files.upload()
If you have a direct link to the download, you can generally use wget
to download it.
!wget http://images.cocodataset.org/zips/unlabeled2017.zip -P data