pyg-team / pytorch_geometric

Graph Neural Network Library for PyTorch
https://pyg.org
MIT License
21.41k stars 3.67k forks source link

Build Pytorch geometric in Docker #934

Open bxclib2 opened 4 years ago

bxclib2 commented 4 years ago

Hi, I tried to build the Pytorch geometric in Docker, and I checked the installation guide check:

user@2d5c3522ea09:/app$ python -c "import torch; print(torch.version)" 1.2.0 user@2d5c3522ea09:/app$ python -c "import torch; print(torch.cuda.is_available())" True user@2d5c3522ea09:/app$ echo $PATH /home/user/miniconda/envs/py36/bin:/home/user/miniconda/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin user@2d5c3522ea09:/app$ echo $CPATH

user@2d5c3522ea09:/app$ export CPATH=/usr/local/cuda/include:$CPATH user@2d5c3522ea09:/app$ echo $CPATH /usr/local/cuda/include: user@2d5c3522ea09:/app$ export CPATH=/usr/local/cuda/include:$CPATH \ && export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH \ && export PATH=/usr/local/cuda/bin:$PATH user@2d5c3522ea09:/app$ user@2d5c3522ea09:/app$ echo $PATH /usr/local/cuda/bin:/home/user/miniconda/envs/py36/bin:/home/user/miniconda/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin user@2d5c3522ea09:/app$ echo $CPATH /usr/local/cuda/include:/usr/local/cuda/include: user@2d5c3522ea09:/app$ echo $LD_LIBRARY_PATH /usr/local/cuda/lib64:/usr/local/nvidia/lib:/usr/local/nvidia/lib64 user@2d5c3522ea09:/app$ nvcc --version nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2018 NVIDIA Corporation Built on Sat_Aug_25_21:08:01_CDT_2018 Cuda compilation tools, release 10.0, V10.0.130 user@2d5c3522ea09:/app$ python -c "import torch; print(torch.version.cuda)" 10.0.130 user@2d5c3522ea09:/app$

The docker file is like this:

FROM anibali/pytorch:cuda-10.0

RUN pip install mysql-connector \ && sudo apt-get update \ && sudo apt-get install libmysqlclient-dev -y \ && sudo apt-get install gcc -y \ && sudo apt-get install build-essential -y \ && pip install mysqlclient

RUN sudo apt-get install -y cuda-core-10-0

RUN export CPATH=/usr/local/cuda/include:$CPATH \ && export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH \ && export PATH=/usr/local/cuda/bin:$PATH

RUN pip install --verbose --no-cache-dir torch-scatter \ && pip install --verbose --no-cache-dir torch-sparse \ && pip install --verbose --no-cache-dir torch-cluster \ && pip install --verbose --no-cache-dir torch-spline-conv \ && pip install torch-geometric

However, I finished with an error:

Collecting torch-scatter 1 location(s) to search for versions of torch-scatter:

How can I solve it? Thank you in advance.

mlaprise commented 4 years ago

Your base image most likely comes with the cuda runtime only. PyG-related package like scatter/cluster needs the dev library in order to be compiled. I installed PyG successfully in the past by using a base image with the dev library like nvidia/cuda:10.1-cudnn7-devel-ubuntu18.04. I also recommend using a multistage building Dockerfile to reduce the size of the final image.