Getting DeepChem running in Colab

I’ve recently started hacking with DeepChem in Colab. I thought it might be useful to post the recipe here for any other folks who are interested in using Colab. Paste the following into your first cell in your Colab notebook:

!wget -c https://repo.anaconda.com/archive/Anaconda3-2019.10-Linux-x86_64.sh
!chmod +x Anaconda3-2019.10-Linux-x86_64.sh
!bash ./Anaconda3-2019.10-Linux-x86_64.sh -b -f -p /usr/local
!conda install -y -c deepchem -c rdkit -c conda-forge -c omnia deepchem-gpu=2.3.0
import sys
sys.path.append('/usr/local/lib/python3.7/site-packages/')
import deepchem as dc

Happy hacking! Post on this issue if you run into any problems

Edit: Google’s updated their Colab instances to use TensorFlow 2.X by default. The last stable version of DeepChem is still on TensorFlow 1.X. You can make sure your colab notebook runs by adding the following command at the top of your Colab notebook:

%tensorflow_version 1.x
5 Likes

Thank you for this. I hope to be use Colab notebook as I often have problem installing Deepchem on Windows using Anaconda.

2 Likes

Hi,
Thank you for sharing this code. I’ve used it successfully in the past in Colab, but have been recently been running into an:

ImportError: cannot import name ‘NewCheckpointReader’

Do you have any suggestions here?
Thank you

1 Like

I think Google colab just updated to use TF2.X as default. You can fix this by adding a magic command to the top of your colab notebook:

%tensorflow_version 1.x

I’ll update the post above with this command too

1 Like

The latest command is here. Please try it!

%tensorflow_version 1.x
!curl -Lo deepchem_installer.py https://raw.githubusercontent.com/deepchem/deepchem/master/scripts/colab_install.py
import deepchem_installer
deepchem_installer.install(version='2.3.0')
3 Likes

For some reason, using this command in Colab throws an error:

TypeError: install() got an unexpected keyword argument 'version'

Do you know by a chance how to fix the command?

1 Like

@GreenTail
You try the new command!

!curl -Lo conda_installer.py https://raw.githubusercontent.com/deepchem/deepchem/master/scripts/colab_install.py
import conda_installer
conda_installer.install()
!/root/miniconda/bin/conda info -e
!pip install --pre deepchem
import deepchem
deepchem.__version__

Now, we are updating the tutorial notebooks for the latest DeepChem version.

4 Likes

FYI since Colab decided not not tell anyone and upgrade to python 3.7 ~2 weeks ago, everything is broken. Using the colab_install.py script does not work, but luckily @bharath’s original code from Feb '20 still works - at least for deepchem 2.3!

Ah that’s worrying! Could you raise an issue on github with the error you’re seeing? We’ll try to get this fixed as soon as possible

1 Like

I went to recreate this error and it looks like it does not happen with the pip install --pre deepchem command - false alarm. I need DeepChem 2.3 for some of my software that has it as a dependency, but I know that’s an edge case, and the conda-forge installation works for that.

1 Like