dmlc / dgl

Python package built to ease deep learning on graph, on top of existing DL frameworks.
http://dgl.ai
Apache License 2.0
13.51k stars 3.02k forks source link

Build ignores the environment variable DGLBACKEND=tensorflow and still import torch #5661

Open yurivict opened 1 year ago

yurivict commented 1 year ago

šŸ› Bug

The documentation says that DGLBACKEND sets the backend. However, with DGLBACKEND=tensorflow it still imports torch:

make[2]: Leaving directory '/usr/ports/math/dgl/work/dgl-1.1.0/third_party/libxsmm'
make[2]: Nothing to be done for 'libxsmm'.
make[2]: Leaving directory '/usr/ports/math/dgl/work/dgl-1.1.0/third_party/libxsmm'
[100% 2/2] cd /usr/ports/math/dgl/work/dgl-1.1.0/dgl_sparse && /usr/local/bin/cmake -E env CMAKE_COMMAND=/usr/local/bin/cmake CUDA_TOOLKIT_ROOT_DIR= USE_CUDA=OFF BINDIR=/usr/ports/math/dgl/work/.build INCLUDEDIR="/usr/ports/math/dgl/work/dgl-1.1.0/include /usr/ports/math/dgl/work/dgl-1.1.0/third_party/dlpack/include /usr/ports/math/dgl/work/dgl-1.1.0/third_party/dmlc-core/include /usr/ports/math/dgl/work/dgl-1.1.0/third_party/phmap/ /usr/ports/math/dgl/work/dgl-1.1.0/third_party/xbyak/ /usr/ports/math/dgl/work/dgl-1.1.0/third_party/METIS/include/ /usr/ports/math/dgl/work/dgl-1.1.0/tensoradapter/include /usr/ports/math/dgl/work/dgl-1.1.0/third_party/nanoflann/include /usr/ports/math/dgl/work/dgl-1.1.0/third_party/libxsmm/include /usr/ports/math/dgl/work/dgl-1.1.0/third_party/pcg/include /usr/ports/math/dgl/work/dgl-1.1.0/third_party/METIS/GKlib /usr/ports/math/dgl/work/dgl-1.1.0/third_party/METIS/include /usr/ports/math/dgl/work/dgl-1.1.0/third_party/tensorpipe" CFLAGS=-fopenmp=libomp\ -O2\ \ -fPIC\ -O2\ -pipe\ \ -fstack-protector-strong\ -fno-strict-aliasing\ -DUSE_LIBXSMM\ -DDGL_CPU_LLC_SIZE=40000000\ -DIDXTYPEWIDTH=64\ -DREALTYPEWIDTH=32\ -DLINUX\ -D_FILE_OFFSET_BITS=64\ -DNDEBUG\ -DNDEBUG2\ -DHAVE_EXECINFO_H\ -DHAVE_GETLINE\ -O3\ \ -Wall\ -Wl,--exclude-libs,ALL CXXFLAGS=-fopenmp=libomp\ -O2\ \ -fPIC\ -std=c++14\ -O2\ -pipe\ -fstack-protector-strong\ -fno-strict-aliasing\ -DUSE_LIBXSMM\ -DDGL_CPU_LLC_SIZE=40000000\ -DIDXTYPEWIDTH=64\ -DREALTYPEWIDTH=32\ \ -Wall\ -Wl,--exclude-libs,ALL LDFLAGS=-Wl,--warn-common\ \ -fstack-protector-strong bash /usr/ports/math/dgl/work/dgl-1.1.0/dgl_sparse/build.sh python3
FAILED: CMakeFiles/dgl_sparse /usr/ports/math/dgl/work/.build/CMakeFiles/dgl_sparse 
cd /usr/ports/math/dgl/work/dgl-1.1.0/dgl_sparse && /usr/local/bin/cmake -E env CMAKE_COMMAND=/usr/local/bin/cmake CUDA_TOOLKIT_ROOT_DIR= USE_CUDA=OFF BINDIR=/usr/ports/math/dgl/work/.build INCLUDEDIR="/usr/ports/math/dgl/work/dgl-1.1.0/include /usr/ports/math/dgl/work/dgl-1.1.0/third_party/dlpack/include /usr/ports/math/dgl/work/dgl-1.1.0/third_party/dmlc-core/include /usr/ports/math/dgl/work/dgl-1.1.0/third_party/phmap/ /usr/ports/math/dgl/work/dgl-1.1.0/third_party/xbyak/ /usr/ports/math/dgl/work/dgl-1.1.0/third_party/METIS/include/ /usr/ports/math/dgl/work/dgl-1.1.0/tensoradapter/include /usr/ports/math/dgl/work/dgl-1.1.0/third_party/nanoflann/include /usr/ports/math/dgl/work/dgl-1.1.0/third_party/libxsmm/include /usr/ports/math/dgl/work/dgl-1.1.0/third_party/pcg/include /usr/ports/math/dgl/work/dgl-1.1.0/third_party/METIS/GKlib /usr/ports/math/dgl/work/dgl-1.1.0/third_party/METIS/include /usr/ports/math/dgl/work/dgl-1.1.0/third_party/tensorpipe" CFLAGS=-fopenmp=libomp\ -O2\ \ -fPIC\ -O2\ -pipe\ \ -fstack-protector-strong\ -fno-strict-aliasing\ -DUSE_LIBXSMM\ -DDGL_CPU_LLC_SIZE=40000000\ -DIDXTYPEWIDTH=64\ -DREALTYPEWIDTH=32\ -DLINUX\ -D_FILE_OFFSET_BITS=64\ -DNDEBUG\ -DNDEBUG2\ -DHAVE_EXECINFO_H\ -DHAVE_GETLINE\ -O3\ \ -Wall\ -Wl,--exclude-libs,ALL CXXFLAGS=-fopenmp=libomp\ -O2\ \ -fPIC\ -std=c++14\ -O2\ -pipe\ -fstack-protector-strong\ -fno-strict-aliasing\ -DUSE_LIBXSMM\ -DDGL_CPU_LLC_SIZE=40000000\ -DIDXTYPEWIDTH=64\ -DREALTYPEWIDTH=32\ \ -Wall\ -Wl,--exclude-libs,ALL LDFLAGS=-Wl,--warn-common\ \ -fstack-protector-strong bash /usr/ports/math/dgl/work/dgl-1.1.0/dgl_sparse/build.sh python3
-DCUDA_TOOLKIT_ROOT_DIR= -DTORCH_CUDA_ARCH_LIST= -DUSE_CUDA=OFF -DDGL_INCLUDE_DIRS=/usr/ports/math/dgl/work/dgl-1.1.0/include;/usr/ports/math/dgl/work/dgl-1.1.0/third_party/dlpack/include;/usr/ports/math/dgl/work/dgl-1.1.0/third_party/dmlc-core/include;/usr/ports/math/dgl/work/dgl-1.1.0/third_party/phmap/;/usr/ports/math/dgl/work/dgl-1.1.0/third_party/xbyak/;/usr/ports/math/dgl/work/dgl-1.1.0/third_party/METIS/include/;/usr/ports/math/dgl/work/dgl-1.1.0/tensoradapter/include;/usr/ports/math/dgl/work/dgl-1.1.0/third_party/nanoflann/include;/usr/ports/math/dgl/work/dgl-1.1.0/third_party/libxsmm/include;/usr/ports/math/dgl/work/dgl-1.1.0/third_party/pcg/include;/usr/ports/math/dgl/work/dgl-1.1.0/third_party/METIS/GKlib;/usr/ports/math/dgl/work/dgl-1.1.0/third_party/METIS/include;/usr/ports/math/dgl/work/dgl-1.1.0/third_party/tensorpipe -DDGL_BUILD_DIR=/usr/ports/math/dgl/work/.build
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'torch'
ninja: build stopped: subcommand failed.
===> Compilation failed unexpectedly.

To Reproduce

cmake configure + build.

Environment

Rhett-Ying commented 1 year ago

@yurivict dgl_sparse is supported with Pytorch backend only. So please append -DBUILD_SPARSE=OFF to cmake.

yurivict commented 1 year ago

Maybe cmake should automatically disable parts that aren't compatible with the currently selected backend, and let the user know that some parts where disabled for the reason of incompatibility.

This would prevent confusion like this.

Rhett-Ying commented 1 year ago

DGLBACKEND is not used in cmake stage. But actually we could print more clear error or disable dgl_spare build if backend is not torch.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale due to lack of activity. It will be closed if no further activity occurs. Thank you

jermainewang commented 1 year ago

Converting this to a feature request. I agree with @Rhett-Ying that we should add a check to bypass dgl.sparse when backend is not pytorch. Also, wonder why our CI doesn't catch this error.