Skip to content

TorchDrug for Ubuntu 18.04 without Anaconda #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
kormilitzin opened this issue Aug 12, 2021 · 10 comments
Open

TorchDrug for Ubuntu 18.04 without Anaconda #4

kormilitzin opened this issue Aug 12, 2021 · 10 comments
Labels
compatibility Not compatible with new dependencies installation Problems in installation

Comments

@kormilitzin
Copy link

What is the simplest way to install it with pip on Ubuntu 18.04 please?

I have successfully installed all requirements, however, it can't find the RDKit:

ModuleNotFoundError: No module named 'rdkit'

To install it, I used: sudo apt-get install python-rdkit librdkit1 rdkit-data as per RDKit

Any ideas, how to run this awesome library without Anaconda please?

@rmurphy2718
Copy link

I also encountered installation issues and wrote a blog post on the steps that eventually let me install.
https://rmurphy2718.github.io//posts/2021/08/torch-drug-install/

I used conda, but mostly pip calls from within my conda env. So, I think you should be able to adapt my solution.

I am sure the devs will streamline the installation process. But, for now, we can use these steps to dig into the repo, learn about it, and continue to iron out kinks!

@KiddoZhu
Copy link
Member

Hi! There is a RDKit available on pip, although we didn't test much in this way. You may try

pip install rdkit-pypi

The library doesn't require full Anaconda and Miniconda is enough. We will also come up with a guide for pip installation.

@KiddoZhu KiddoZhu added the installation Problems in installation label Aug 13, 2021
@shichence
Copy link
Contributor

shichence commented Aug 13, 2021

Thanks @rmurphy2718 for the nice blog!
I just successfully installed torchdrug (cpu version) on my Macos using venv without Anaconda. Here is a possible solution.

Create venv

mkdir .venv
/usr/bin/python3 -m venv ~/.venv/torchdrug
source ~/.venv/torchdrug/bin/activate
pip install --upgrade pip setuptools wheel

Note that we have only tested python 3.7/3.8. There may be some metaclass-related bugs on other python versions.

Install requirements

# Contents in requirements.txt
torch<1.9.0,>=1.4.0
decorator<5,>=4.3
numpy>=1.11
matplotlib
tqdm
networkx
ninja
jinja2
rdkit-pypi

pip install -r requirements.txt
Currently, we exclude the PyTorch 1.9 because we find an import container_abcs issue related to Pytorch version.
(See NVIDIA/apex#1049 and facebookresearch/TimeSformer#47)
We will fix this small bug in the next version.

Install torch scatter according to your PyTorch version

PyTorch 1.9.0

pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.9.0+${CUDA}.html
pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.9.0+cpu.html

PyTorch 1.8.0/1.8.1

pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.8.0+${CUDA}.html
pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.8.0+cpu.html

Note: Binaries of older versions are also provided for PyTorch 1.4.0, PyTorch 1.5.0, PyTorch 1.6.0 and PyTorch 1.7.0/1.7.1 (following the same procedure).
See https://github.com/rusty1s/pytorch_scatter for more details.

Install torchdrug

git clone https://github.com/DeepGraphLearning/torchdrug
cd torchdrug
python setup.py install

We will update the readme to make the installation much easier on different machines soon

@shichence
Copy link
Contributor

shichence commented Aug 13, 2021

Update

Generally, it is not recommended to install RDKit via pip (pip install rdkit-pypi).
Everything works smoothly with conda.

Problem Statement

I found that if you do so, you will probably meet the following error:

ModuleNotFoundError: No module named 'sascorer'

The torchdrug relies on the sascorer module, which is an extension provided by RDKit.
The way to load sascorer is illustrated in

sys.path.append(os.path.join(RDConfig.RDContribDir, "SA_Score"))

Usually, a Contrib directory is located at the place specified by rdkit.Chem.RDConfig.RDContribDir.
However, I find the RDKit installed via pip fails to include this directory in the right place.

Workaround

See rdkit/rdkit#2279 for extra information on how to using the rdkit.Contrib.

@kormilitzin
Copy link
Author

kormilitzin commented Aug 13, 2021

Thank you all. I just followed the advices of @rmurphy2718 , @KiddoZhu and @shichence and all worked as a charm.
However, I install PyTorch 1.9.0 as I got the same error with container_abcs.

Specifically, on my Linux system with Ubuntu 18.04,Python 3.9.6 and CUDA 11.1, I created a new ./venv, activated and:

pip install --upgrade pip setuptools wheel
pip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 torchaudio==0.8.0 -f https://download.pytorch.org/whl/torch_stable.html
pip install decorator numpy matplotlib tqdm networkx ninja jinja2 rdkit-pypi jupyterlab pandas
pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.8.0+cu111.html

Then I followed the installation from source as in above:

git clone https://github.com/DeepGraphLearning/torchdrug
cd torchdrug
python setup.py install

And all worked well. I hope it helps.

P.S. I didn't encounter the problem mentioned by @shichence with ModuleNotFoundError: No module named 'sascorer'.

@KiddoZhu KiddoZhu added the compatibility Not compatible with new dependencies label Aug 13, 2021
@KiddoZhu
Copy link
Member

FYI. I use PyTorch 1.8.1 (py3.7_cuda10.2_cudnn7.6.5_0) from conda, and there is no complaint about container_abcs.

TorchDrug just slightly depends on container_abcs. We will refactor this part to make sure it is compatible with newer PyTorch versions.

@KiddoZhu
Copy link
Member

The metaclass issue is fixed in d187dd8

@KiddoZhu
Copy link
Member

sascorer is now integrated as a part of TorchDrug in f14caf7. We test pip installation on Colab and it works pretty well. So I guess there should be no trouble for installation without Anaconda.

@chaitjo
Copy link

chaitjo commented Oct 4, 2021

Hi torchdrug team! Thanks for the great library, and I am looking forward to it growing further!

I also encountered installation issues when directly running the conda installation. My system was Ubuntu 18.04, Python 3.8, CUDA 11.0.

In case it helps anyone else, here are the set of commands that I used to get the tutorials up and running, initially (will continue to test if I encounter any issues):

conda create -n torchdrug python=3.8
conda activate torchdrug
conda install pytorch=1.7.1 cudatoolkit=11.0 -c pytorch
pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.7.1+cu110.html
pip install torchdrug

I suspect that the direct conda installation is not able to install the correct version of torch-scatter for my CUDA version.

@KiddoZhu
Copy link
Member

KiddoZhu commented Oct 4, 2021

Yes. I think the major issue for conda install is the version of torch-scatter. A crappy solution is to install a non-official torch-scatter build (only available for PyTorch 1.4.* & 1.5.*), which provides a better version check than the official one.

conda install pytorch torch-scatter -c pytorch -c ostrokach-forge 

We will check if there is any better solution for installation of the official torch-scatter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility Not compatible with new dependencies installation Problems in installation
Projects
None yet
Development

No branches or pull requests

5 participants