torchdrug
torchdrug copied to clipboard
TorchDrug for Ubuntu 18.04 without Anaconda
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?
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!
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.
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 https://github.com/NVIDIA/apex/pull/1049 and https://github.com/facebookresearch/TimeSformer/pull/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
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 https://github.com/DeepGraphLearning/torchdrug/blob/356e1ce259d60dac9fa4f3515d8d346f1d73369f/torchdrug/metrics/metric.py#L15
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
-
If you insist on installing RDKit via pip and meet the above bug, you may manually download the
Contrib
dir from https://github.com/rdkit/rdkit/tree/master/Contrib, and put them in the right place specified byrdkit.Chem.RDConfig.RDContribDir
. -
On my machine, I would download Contrib from https://github.com/rdkit/rdkit/tree/master/Contrib and then put the whole directory into
~/.venv/torchdrug/lib/python3.7/site-packages/rdkit/
See https://github.com/rdkit/rdkit/issues/2279 for extra information on how to using the rdkit.Contrib
.
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'
.
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.
The metaclass issue is fixed in d187dd8
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.
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.
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.