diff --git a/.gitignore b/.gitignore index 44a1471fefc..7bd759bbc10 100644 --- a/.gitignore +++ b/.gitignore @@ -29,11 +29,15 @@ junit-cugraph.xml test-results ## Python build directories & artifacts +dask-worker-space/ htmlcov dist/ cugraph.egg-info/ python/build python/cugraph/bindings/*.cpp +wheels/ +_skbuild/ +cufile.log ## pylibcugraph build directories & artifacts python/pylibcugraph/pylibcugraph.egg-info diff --git a/build.sh b/build.sh index 1182adfa0ef..79dd0f91dce 100755 --- a/build.sh +++ b/build.sh @@ -159,6 +159,8 @@ if hasArg clean; then pushd ${REPODIR}/python > /dev/null rm -rf dist dask-worker-space cugraph/raft *.egg-info find . -name "__pycache__" -type d -exec rm -rf {} \; > /dev/null 2>&1 + find . -type d -name _skbuild -exec rm -rf {} \; > /dev/null 2>&1 + find . -type d -name dist -exec rm -rf {} \; > /dev/null 2>&1 find . -name "*.cpp" -type f -delete find . -name "*.cpython*.so" -type f -delete find . -type d -name _external_repositories -exec rm -rf {} \; > /dev/null 2>&1 @@ -230,7 +232,8 @@ if buildAll || hasArg pylibcugraph; then # setup.py references an env var CUGRAPH_BUILD_PATH to find the libcugraph # build. If not set by the user, set it to LIBCUGRAPH_BUILD_DIR CUGRAPH_BUILD_PATH=${CUGRAPH_BUILD_PATH:=${LIBCUGRAPH_BUILD_DIR}} - env CUGRAPH_BUILD_PATH=${CUGRAPH_BUILD_PATH} python setup.py build_ext --inplace --library-dir=${LIBCUGRAPH_BUILD_DIR} + python setup.py build_ext --inplace -- -DFIND_CUGRAPH_CPP=ON \ + -Dcugraph_ROOT=${LIBCUGRAPH_BUILD_DIR} -- -j${PARALLEL_LEVEL:-1} if [[ ${INSTALL_TARGET} != "" ]]; then env CUGRAPH_BUILD_PATH=${CUGRAPH_BUILD_PATH} python setup.py install fi @@ -243,7 +246,8 @@ if buildAll || hasArg cugraph; then # setup.py references an env var CUGRAPH_BUILD_PATH to find the libcugraph # build. If not set by the user, set it to LIBCUGRAPH_BUILD_DIR CUGRAPH_BUILD_PATH=${CUGRAPH_BUILD_PATH:=${LIBCUGRAPH_BUILD_DIR}} - env CUGRAPH_BUILD_PATH=${CUGRAPH_BUILD_PATH} python setup.py build_ext --inplace --library-dir=${LIBCUGRAPH_BUILD_DIR} + python setup.py build_ext --inplace -- -DFIND_CUGRAPH_CPP=ON \ + -Dcugraph_ROOT=${LIBCUGRAPH_BUILD_DIR} -- -j${PARALLEL_LEVEL:-1} if [[ ${INSTALL_TARGET} != "" ]]; then env CUGRAPH_BUILD_PATH=${CUGRAPH_BUILD_PATH} python setup.py install fi diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index c2062a170bd..9aec4bd7a25 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -39,6 +39,9 @@ function sed_runner() { sed -i.bak ''"$1"'' $2 && rm -f ${2}.bak } +# rapids-cmake version +sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' fetch_rapids.cmake + # CMakeLists update sed_runner 's/'"CUGRAPH VERSION .* LANGUAGES C CXX CUDA)"'/'"CUGRAPH VERSION ${NEXT_FULL_TAG} LANGUAGES C CXX CUDA)"'/g' cpp/CMakeLists.txt sed_runner 's|'"branch-.*/RAPIDS.cmake"'|'"branch-${NEXT_SHORT_TAG}/RAPIDS.cmake"'|g' cpp/CMakeLists.txt diff --git a/conda/environments/cugraph_dev_cuda11.2.yml b/conda/environments/cugraph_dev_cuda11.2.yml index 29f4d4d8873..f1f4c0e4570 100644 --- a/conda/environments/cugraph_dev_cuda11.2.yml +++ b/conda/environments/cugraph_dev_cuda11.2.yml @@ -28,6 +28,7 @@ dependencies: - clang=11.1.0 - clang-tools=11.1.0 - cmake>=3.20.1,!=3.23.0 +- scikit-build>=0.13.1 - python>=3.8,<3.10 - notebook>=0.5.0 - boost diff --git a/conda/environments/cugraph_dev_cuda11.4.yml b/conda/environments/cugraph_dev_cuda11.4.yml index 3a387268ff4..fc1ca620e6d 100644 --- a/conda/environments/cugraph_dev_cuda11.4.yml +++ b/conda/environments/cugraph_dev_cuda11.4.yml @@ -28,6 +28,7 @@ dependencies: - clang=11.1.0 - clang-tools=11.1.0 - cmake>=3.20.1,!=3.23.0 +- scikit-build>=0.13.1 - python>=3.8,<3.10 - notebook>=0.5.0 - boost diff --git a/conda/environments/cugraph_dev_cuda11.5.yml b/conda/environments/cugraph_dev_cuda11.5.yml index b8a50a79596..1c901e712cd 100644 --- a/conda/environments/cugraph_dev_cuda11.5.yml +++ b/conda/environments/cugraph_dev_cuda11.5.yml @@ -28,6 +28,7 @@ dependencies: - clang=11.1.0 - clang-tools=11.1.0 - cmake>=3.20.1,!=3.23.0 +- scikit-build>=0.13.1 - python>=3.8,<3.10 - notebook>=0.5.0 - boost diff --git a/conda/recipes/cugraph/conda_build_config.yaml b/conda/recipes/cugraph/conda_build_config.yaml index 322fe6faacf..8db7dbb7923 100644 --- a/conda/recipes/cugraph/conda_build_config.yaml +++ b/conda/recipes/cugraph/conda_build_config.yaml @@ -7,5 +7,8 @@ cxx_compiler_version: cuda_compiler: - nvcc +cmake_version: + - ">=3.20.1,!=3.23.0" + sysroot_version: - "2.17" diff --git a/conda/recipes/cugraph/meta.yaml b/conda/recipes/cugraph/meta.yaml index 37ec823dc87..022618fa22a 100644 --- a/conda/recipes/cugraph/meta.yaml +++ b/conda/recipes/cugraph/meta.yaml @@ -25,6 +25,7 @@ build: requirements: build: + - cmake {{ cmake_version }} - {{ compiler('c') }} - {{ compiler('cxx') }} - {{ compiler('cuda') }} {{ cuda_version }} @@ -32,6 +33,7 @@ requirements: host: - python x.x - cython>=0.29,<0.30 + - scikit-build>=0.13.1 - libcugraph={{ version }} - libraft-headers {{ minor_version }} - pyraft {{ minor_version }} diff --git a/conda/recipes/pylibcugraph/conda_build_config.yaml b/conda/recipes/pylibcugraph/conda_build_config.yaml index 322fe6faacf..8db7dbb7923 100644 --- a/conda/recipes/pylibcugraph/conda_build_config.yaml +++ b/conda/recipes/pylibcugraph/conda_build_config.yaml @@ -7,5 +7,8 @@ cxx_compiler_version: cuda_compiler: - nvcc +cmake_version: + - ">=3.20.1,!=3.23.0" + sysroot_version: - "2.17" diff --git a/conda/recipes/pylibcugraph/meta.yaml b/conda/recipes/pylibcugraph/meta.yaml index a6dec1d50ba..4a2a178516a 100644 --- a/conda/recipes/pylibcugraph/meta.yaml +++ b/conda/recipes/pylibcugraph/meta.yaml @@ -25,6 +25,7 @@ build: requirements: build: + - cmake {{ cmake_version }} - {{ compiler('c') }} - {{ compiler('cxx') }} - {{ compiler('cuda') }} {{ cuda_version }} @@ -32,6 +33,7 @@ requirements: host: - python x.x - cython>=0.29,<0.30 + - scikit-build>=0.13.1 - libcugraph={{ version }} - ucx-py {{ ucx_py_version }} - ucx-proc=*=gpu diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 7a681c9a99f..7f2feb11cdf 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -15,10 +15,8 @@ #============================================================================= cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) -file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.08/RAPIDS.cmake - ${CMAKE_BINARY_DIR}/RAPIDS.cmake) -include(${CMAKE_BINARY_DIR}/RAPIDS.cmake) +include(../fetch_rapids.cmake) include(rapids-cmake) include(rapids-cpm) include(rapids-cuda) diff --git a/cpp/cmake/thirdparty/get_libcudacxx.cmake b/cpp/cmake/thirdparty/get_libcudacxx.cmake index 41e5998a448..1c51c5a84a9 100644 --- a/cpp/cmake/thirdparty/get_libcudacxx.cmake +++ b/cpp/cmake/thirdparty/get_libcudacxx.cmake @@ -16,8 +16,7 @@ function(find_and_configure_libcudacxx) include(${rapids-cmake-dir}/cpm/libcudacxx.cmake) - rapids_cpm_libcudacxx(BUILD_EXPORT_SET cugraph-exports - INSTALL_EXPORT_SET cugraph-exports) + rapids_cpm_libcudacxx(BUILD_EXPORT_SET cugraph-exports) endfunction() diff --git a/fetch_rapids.cmake b/fetch_rapids.cmake new file mode 100644 index 00000000000..2b5c7e9d352 --- /dev/null +++ b/fetch_rapids.cmake @@ -0,0 +1,17 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= +file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.08/RAPIDS.cmake + ${CMAKE_BINARY_DIR}/RAPIDS.cmake +) +include(${CMAKE_BINARY_DIR}/RAPIDS.cmake) diff --git a/python/cugraph/CMakeLists.txt b/python/cugraph/CMakeLists.txt new file mode 100644 index 00000000000..f90035f9460 --- /dev/null +++ b/python/cugraph/CMakeLists.txt @@ -0,0 +1,84 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) + +set(cugraph_version 22.08.00) + +include(../../fetch_rapids.cmake) + +project( + cugraph-python + VERSION ${cugraph_version} + LANGUAGES # TODO: Building Python extension modules via the python_extension_module requires the C + # language to be enabled here. The test project that is built in scikit-build to verify + # various linking options for the python library is hardcoded to build with C, so until + # that is fixed we need to keep C. + C CXX +) + +################################################################################ +# - User Options -------------------------------------------------------------- +option(FIND_CUGRAPH_CPP "Search for existing CUGRAPH C++ installations before defaulting to local files" + OFF +) + +# If the user requested it, we attempt to find CUGRAPH. +if(FIND_CUGRAPH_CPP) + find_package(cugraph ${cugraph_version} REQUIRED) +else() + set(cugraph_FOUND OFF) +endif() + +if(NOT cugraph_FOUND) + # TODO: This will not be necessary once we upgrade to CMake 3.22, which will pull in the required + # languages for the C++ project even if this project does not require those languges. + include(rapids-cuda) + rapids_cuda_init_architectures(CUGRAPH) + enable_language(CUDA) + + # Since cugraph only enables CUDA optionally, we need to manually include the file that + # rapids_cuda_init_architectures relies on `project` including. + + include("${CMAKE_PROJECT_cugraph-python_INCLUDE}") + + add_subdirectory(../../cpp cugraph-cpp) + + install(TARGETS cugraph DESTINATION cugraph/library) +endif() + + +include(rapids-cython) +rapids_cython_init() + +add_subdirectory(cugraph/centrality) +add_subdirectory(cugraph/community) +add_subdirectory(cugraph/components) +add_subdirectory(cugraph/cores) +add_subdirectory(cugraph/dask/centrality) +add_subdirectory(cugraph/dask/comms) +add_subdirectory(cugraph/dask/community) +add_subdirectory(cugraph/dask/components) +add_subdirectory(cugraph/dask/link_analysis) +add_subdirectory(cugraph/dask/structure) +add_subdirectory(cugraph/generators) +add_subdirectory(cugraph/internals) +add_subdirectory(cugraph/layout) +add_subdirectory(cugraph/linear_assignment) +add_subdirectory(cugraph/link_analysis) +add_subdirectory(cugraph/link_prediction) +add_subdirectory(cugraph/sampling) +add_subdirectory(cugraph/structure) +add_subdirectory(cugraph/tree) +add_subdirectory(cugraph/utilities) diff --git a/python/cugraph/cugraph/centrality/CMakeLists.txt b/python/cugraph/cugraph/centrality/CMakeLists.txt new file mode 100644 index 00000000000..68b9c244690 --- /dev/null +++ b/python/cugraph/cugraph/centrality/CMakeLists.txt @@ -0,0 +1,29 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +set(cython_sources + betweenness_centrality_wrapper.pyx + edge_betweenness_centrality_wrapper.pyx +) +set(linked_libraries cugraph::cugraph) + +rapids_cython_create_modules( + CXX + SOURCE_FILES "${cython_sources}" + LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX centrality_ +) + +foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) + set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library") +endforeach() diff --git a/python/cugraph/cugraph/community/CMakeLists.txt b/python/cugraph/cugraph/community/CMakeLists.txt new file mode 100644 index 00000000000..db5f9a8a3b1 --- /dev/null +++ b/python/cugraph/cugraph/community/CMakeLists.txt @@ -0,0 +1,34 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +set(cython_sources + ecg_wrapper.pyx egonet_wrapper.pyx + ktruss_subgraph_wrapper.pyx + leiden_wrapper.pyx + louvain_wrapper.pyx + spectral_clustering_wrapper.pyx + subgraph_extraction_wrapper.pyx + triangle_count_wrapper.pyx +) + +set(linked_libraries cugraph::cugraph) +rapids_cython_create_modules( + CXX + SOURCE_FILES "${cython_sources}" + LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX community_ +) + +foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) + set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library") +endforeach() diff --git a/python/cugraph/cugraph/components/CMakeLists.txt b/python/cugraph/cugraph/components/CMakeLists.txt new file mode 100644 index 00000000000..4a6efa3bdb1 --- /dev/null +++ b/python/cugraph/cugraph/components/CMakeLists.txt @@ -0,0 +1,25 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +set(cython_sources connectivity_wrapper.pyx) +set(linked_libraries cugraph::cugraph) +rapids_cython_create_modules( + CXX + SOURCE_FILES "${cython_sources}" + LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX components_ +) + +foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) + set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library") +endforeach() diff --git a/python/cugraph/cugraph/cores/CMakeLists.txt b/python/cugraph/cugraph/cores/CMakeLists.txt new file mode 100644 index 00000000000..c87a8a9c134 --- /dev/null +++ b/python/cugraph/cugraph/cores/CMakeLists.txt @@ -0,0 +1,25 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +set(cython_sources k_core_wrapper.pyx) +set(linked_libraries cugraph::cugraph) +rapids_cython_create_modules( + CXX + SOURCE_FILES "${cython_sources}" + LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX cores_ +) + +foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) + set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library") +endforeach() diff --git a/python/cugraph/cugraph/dask/centrality/CMakeLists.txt b/python/cugraph/cugraph/dask/centrality/CMakeLists.txt new file mode 100644 index 00000000000..035e93f33c0 --- /dev/null +++ b/python/cugraph/cugraph/dask/centrality/CMakeLists.txt @@ -0,0 +1,25 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +set(cython_sources mg_katz_centrality_wrapper.pyx) +set(linked_libraries cugraph::cugraph) +rapids_cython_create_modules( + CXX + SOURCE_FILES "${cython_sources}" + LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX centrality_ +) + +foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) + set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../../library") +endforeach() diff --git a/python/cugraph/cugraph/dask/comms/CMakeLists.txt b/python/cugraph/cugraph/dask/comms/CMakeLists.txt new file mode 100644 index 00000000000..2a287abed6a --- /dev/null +++ b/python/cugraph/cugraph/dask/comms/CMakeLists.txt @@ -0,0 +1,25 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +set(cython_sources comms_wrapper.pyx) +set(linked_libraries cugraph::cugraph) +rapids_cython_create_modules( + CXX + SOURCE_FILES "${cython_sources}" + LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX comms_ +) + +foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) + set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../../library") +endforeach() diff --git a/python/cugraph/cugraph/dask/community/CMakeLists.txt b/python/cugraph/cugraph/dask/community/CMakeLists.txt new file mode 100644 index 00000000000..be33135abfa --- /dev/null +++ b/python/cugraph/cugraph/dask/community/CMakeLists.txt @@ -0,0 +1,25 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +set(cython_sources louvain_wrapper.pyx) +set(linked_libraries cugraph::cugraph) +rapids_cython_create_modules( + CXX + SOURCE_FILES "${cython_sources}" + LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX dask_community_ +) + +foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) + set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../../library") +endforeach() diff --git a/python/cugraph/cugraph/dask/components/CMakeLists.txt b/python/cugraph/cugraph/dask/components/CMakeLists.txt new file mode 100644 index 00000000000..36ef1e216a2 --- /dev/null +++ b/python/cugraph/cugraph/dask/components/CMakeLists.txt @@ -0,0 +1,25 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +set(cython_sources mg_connectivity_wrapper.pyx) +set(linked_libraries cugraph::cugraph) +rapids_cython_create_modules( + CXX + SOURCE_FILES "${cython_sources}" + LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX components_ +) + +foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) + set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../../library") +endforeach() diff --git a/python/cugraph/cugraph/dask/link_analysis/CMakeLists.txt b/python/cugraph/cugraph/dask/link_analysis/CMakeLists.txt new file mode 100644 index 00000000000..b204a6b6927 --- /dev/null +++ b/python/cugraph/cugraph/dask/link_analysis/CMakeLists.txt @@ -0,0 +1,25 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +set(cython_sources mg_pagerank_wrapper.pyx) +set(linked_libraries cugraph::cugraph) +rapids_cython_create_modules( + CXX + SOURCE_FILES "${cython_sources}" + LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX link_analysis_ +) + +foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) + set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../../library") +endforeach() diff --git a/python/cugraph/cugraph/dask/structure/CMakeLists.txt b/python/cugraph/cugraph/dask/structure/CMakeLists.txt new file mode 100644 index 00000000000..afc597cb5d6 --- /dev/null +++ b/python/cugraph/cugraph/dask/structure/CMakeLists.txt @@ -0,0 +1,25 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +set(cython_sources replication.pyx) +set(linked_libraries cugraph::cugraph) +rapids_cython_create_modules( + CXX + SOURCE_FILES "${cython_sources}" + LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX structure_ +) + +foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) + set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../../library") +endforeach() diff --git a/python/cugraph/cugraph/generators/CMakeLists.txt b/python/cugraph/cugraph/generators/CMakeLists.txt new file mode 100644 index 00000000000..6edf6acc903 --- /dev/null +++ b/python/cugraph/cugraph/generators/CMakeLists.txt @@ -0,0 +1,25 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +set(cython_sources rmat_wrapper.pyx) +set(linked_libraries cugraph::cugraph) +rapids_cython_create_modules( + CXX + SOURCE_FILES "${cython_sources}" + LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX generators_ +) + +foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) + set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library") +endforeach() diff --git a/python/cugraph/cugraph/internals/CMakeLists.txt b/python/cugraph/cugraph/internals/CMakeLists.txt new file mode 100644 index 00000000000..461a96615a7 --- /dev/null +++ b/python/cugraph/cugraph/internals/CMakeLists.txt @@ -0,0 +1,27 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +set(cython_sources internals.pyx) +set(linked_libraries cugraph::cugraph) +rapids_cython_create_modules( + CXX + SOURCE_FILES "${cython_sources}" + LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX internals_ +) + +target_include_directories(internals_internals PRIVATE "${CMAKE_CURRENT_LIST_DIR}") + +foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) + set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library") +endforeach() diff --git a/python/cugraph/cugraph/layout/CMakeLists.txt b/python/cugraph/cugraph/layout/CMakeLists.txt new file mode 100644 index 00000000000..96f425cc1ed --- /dev/null +++ b/python/cugraph/cugraph/layout/CMakeLists.txt @@ -0,0 +1,25 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +set(cython_sources force_atlas2_wrapper.pyx) +set(linked_libraries cugraph::cugraph) +rapids_cython_create_modules( + CXX + SOURCE_FILES "${cython_sources}" + LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX layout_ +) + +foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) + set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library") +endforeach() diff --git a/python/cugraph/cugraph/linear_assignment/CMakeLists.txt b/python/cugraph/cugraph/linear_assignment/CMakeLists.txt new file mode 100644 index 00000000000..618c04d1f0a --- /dev/null +++ b/python/cugraph/cugraph/linear_assignment/CMakeLists.txt @@ -0,0 +1,25 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +set(cython_sources lap_wrapper.pyx) +set(linked_libraries cugraph::cugraph) +rapids_cython_create_modules( + CXX + SOURCE_FILES "${cython_sources}" + LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX linear_assignment_ +) + +foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) + set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library") +endforeach() diff --git a/python/cugraph/cugraph/link_analysis/CMakeLists.txt b/python/cugraph/cugraph/link_analysis/CMakeLists.txt new file mode 100644 index 00000000000..30dbe239ea9 --- /dev/null +++ b/python/cugraph/cugraph/link_analysis/CMakeLists.txt @@ -0,0 +1,25 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +set(cython_sources pagerank_wrapper.pyx) +set(linked_libraries cugraph::cugraph) +rapids_cython_create_modules( + CXX + SOURCE_FILES "${cython_sources}" + LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX link_analysis_ +) + +foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) + set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library") +endforeach() diff --git a/python/cugraph/cugraph/link_prediction/CMakeLists.txt b/python/cugraph/cugraph/link_prediction/CMakeLists.txt new file mode 100644 index 00000000000..6b5931775a3 --- /dev/null +++ b/python/cugraph/cugraph/link_prediction/CMakeLists.txt @@ -0,0 +1,25 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +set(cython_sources jaccard_wrapper.pyx overlap_wrapper.pyx) +set(linked_libraries cugraph::cugraph) +rapids_cython_create_modules( + CXX + SOURCE_FILES "${cython_sources}" + LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX link_prediction_ +) + +foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) + set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library") +endforeach() diff --git a/python/cugraph/cugraph/sampling/CMakeLists.txt b/python/cugraph/cugraph/sampling/CMakeLists.txt new file mode 100644 index 00000000000..bb2cee3a6ec --- /dev/null +++ b/python/cugraph/cugraph/sampling/CMakeLists.txt @@ -0,0 +1,25 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +set(cython_sources random_walks_wrapper.pyx) +set(linked_libraries cugraph::cugraph) +rapids_cython_create_modules( + CXX + SOURCE_FILES "${cython_sources}" + LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX sampling_ +) + +foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) + set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library") +endforeach() diff --git a/python/cugraph/cugraph/structure/CMakeLists.txt b/python/cugraph/cugraph/structure/CMakeLists.txt new file mode 100644 index 00000000000..8dbd9e29c71 --- /dev/null +++ b/python/cugraph/cugraph/structure/CMakeLists.txt @@ -0,0 +1,25 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +set(cython_sources graph_primtypes_wrapper.pyx graph_primtypes.pyx renumber_wrapper.pyx utils_wrapper.pyx) +set(linked_libraries cugraph::cugraph) +rapids_cython_create_modules( + CXX + SOURCE_FILES "${cython_sources}" + LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX structure_ +) + +foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) + set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library") +endforeach() diff --git a/python/cugraph/cugraph/tree/CMakeLists.txt b/python/cugraph/cugraph/tree/CMakeLists.txt new file mode 100644 index 00000000000..389a1825117 --- /dev/null +++ b/python/cugraph/cugraph/tree/CMakeLists.txt @@ -0,0 +1,25 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +set(cython_sources minimum_spanning_tree_wrapper.pyx) +set(linked_libraries cugraph::cugraph) +rapids_cython_create_modules( + CXX + SOURCE_FILES "${cython_sources}" + LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX tree_ +) + +foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) + set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library") +endforeach() diff --git a/python/cugraph/cugraph/utilities/CMakeLists.txt b/python/cugraph/cugraph/utilities/CMakeLists.txt new file mode 100644 index 00000000000..b4e5a7195ee --- /dev/null +++ b/python/cugraph/cugraph/utilities/CMakeLists.txt @@ -0,0 +1,25 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +set(cython_sources path_retrieval_wrapper.pyx) +set(linked_libraries cugraph::cugraph) +rapids_cython_create_modules( + CXX + SOURCE_FILES "${cython_sources}" + LINKED_LIBRARIES "${linked_libraries}" MODULE_PREFIX utilities_ +) + +foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) + set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library") +endforeach() diff --git a/python/cugraph/pyproject.toml b/python/cugraph/pyproject.toml new file mode 100644 index 00000000000..ac4538c41f7 --- /dev/null +++ b/python/cugraph/pyproject.toml @@ -0,0 +1,12 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. + +[build-system] + +requires = [ + "wheel", + "setuptools", + "cython>=0.29,<0.30", + "scikit-build>=0.13.1", + "cmake>=3.20.1,!=3.23.0", + "ninja", +] diff --git a/python/cugraph/setup.py b/python/cugraph/setup.py index c2d994969c0..ec50090cd43 100644 --- a/python/cugraph/setup.py +++ b/python/cugraph/setup.py @@ -12,26 +12,10 @@ # limitations under the License. import os -import sys -import sysconfig import shutil -# Must import in this order: -# setuptools -> Cython.Distutils.build_ext -> setuptools.command.build_ext -# Otherwise, setuptools.command.build_ext ends up inheriting from -# Cython.Distutils.old_build_ext which we do not want -import setuptools - -try: - from Cython.Distutils.build_ext import new_build_ext as _build_ext -except ImportError: - from setuptools.command.build_ext import build_ext as _build_ext - -from distutils.sysconfig import get_python_lib - -import setuptools.command.build_ext -from setuptools import find_packages, setup, Command -from setuptools.extension import Extension +from setuptools import find_packages, Command +from skbuild import setup from setuputils import get_environment_option @@ -39,24 +23,8 @@ INSTALL_REQUIRES = ['numba', 'cython'] -CYTHON_FILES = ['cugraph/**/*.pyx'] -UCX_HOME = get_environment_option("UCX_HOME") CUDA_HOME = get_environment_option('CUDA_HOME') -CONDA_PREFIX = get_environment_option('CONDA_PREFIX') - -conda_lib_dir = os.path.normpath(sys.prefix) + '/lib' -conda_include_dir = os.path.normpath(sys.prefix) + '/include' - -if CONDA_PREFIX: - conda_include_dir = CONDA_PREFIX + '/include' - conda_lib_dir = CONDA_PREFIX + '/lib' - -if not UCX_HOME: - UCX_HOME = CONDA_PREFIX if CONDA_PREFIX else os.sys.prefix - -ucx_include_dir = os.path.join(UCX_HOME, "include") -ucx_lib_dir = os.path.join(UCX_HOME, "lib") if not CUDA_HOME: path_to_cuda_gdb = shutil.which("cuda-gdb") @@ -74,40 +42,6 @@ "Invalid CUDA_HOME: " "directory does not exist: {CUDA_HOME}" ) -cuda_include_dir = os.path.join(CUDA_HOME, "include") -cuda_lib_dir = os.path.join(CUDA_HOME, "lib64") - -# Optional location of C++ build folder that can be configured by the user -libcugraph_path = get_environment_option('CUGRAPH_BUILD_PATH') - -if not libcugraph_path: - libcugraph_path = conda_lib_dir - -extensions = [ - Extension("*", - sources=CYTHON_FILES, - include_dirs=[ - conda_include_dir, - ucx_include_dir, - '../cpp/include', - "../thirdparty/cub", - os.path.join(conda_include_dir, "libcudacxx"), - cuda_include_dir, - os.path.dirname(sysconfig.get_path("include")) - ], - library_dirs=[ - get_python_lib(), - conda_lib_dir, - libcugraph_path, - ucx_lib_dir, - cuda_lib_dir, - os.path.join(os.sys.prefix, "lib") - ], - libraries=['cudart', 'cusparse', 'cusolver', 'cugraph', 'nccl'], - language='c++', - extra_compile_args=['-std=c++17']) -] - class CleanCommand(Command): """Custom clean command to tidy up the project root.""" @@ -129,51 +63,18 @@ def run(self): os.system('rm -rf *.egg-info') os.system('find . -name "*.cpp" -type f -delete') os.system('find . -name "*.cpython*.so" -type f -delete') + os.system('rm -rf _skbuild') -class build_ext_no_debug(_build_ext): - - def build_extensions(self): - def remove_flags(compiler, *flags): - for flag in flags: - try: - compiler.compiler_so = list( - filter((flag).__ne__, compiler.compiler_so) - ) - except Exception: - pass - # Full optimization - self.compiler.compiler_so.append("-O3") - # No debug symbols, full optimization, no '-Wstrict-prototypes' warning - remove_flags( - self.compiler, "-g", "-G", "-O1", "-O2", "-Wstrict-prototypes" - ) - super().build_extensions() - - def finalize_options(self): - if self.distribution.ext_modules: - # Delay import this to allow for Cython-less installs - from Cython.Build.Dependencies import cythonize - - nthreads = getattr(self, "parallel", None) # -j option in Py3.5+ - nthreads = int(nthreads) if nthreads else None - self.distribution.ext_modules = cythonize( - self.distribution.ext_modules, - nthreads=nthreads, - force=self.force, - gdb_debug=False, - compiler_directives=dict( - profile=False, language_level=3, embedsignature=True - ), - ) - # Skip calling super() and jump straight to setuptools - setuptools.command.build_ext.build_ext.finalize_options(self) - - -cmdclass = dict() -cmdclass.update(versioneer.get_cmdclass()) -cmdclass["build_ext"] = build_ext_no_debug +cmdclass = versioneer.get_cmdclass() cmdclass["clean"] = CleanCommand +PACKAGE_DATA = { + key: ["*.pxd"] for key in find_packages(include=["cugraph*"])} + +PACKAGE_DATA['cugraph.experimental.datasets'].extend( + ['cugraph/experimental/datasets/metadata/*.yaml', + 'cugraph/experimental/datasets/*.yaml']) + setup(name='cugraph', description="cuGraph - RAPIDS GPU Graph Analytics", @@ -189,13 +90,9 @@ def finalize_options(self): # Include the separately-compiled shared library author="NVIDIA Corporation", setup_requires=['Cython>=0.29,<0.30'], - ext_modules=extensions, packages=find_packages(include=['cugraph', 'cugraph.*']), + package_data=PACKAGE_DATA, include_package_data=True, - package_data={ - '': ['python/cugraph/cugraph/experimental/datasets/metadata/*.yaml', - 'python/cugraph/cugraph/experimental/datasets/*.yaml'], - }, install_requires=INSTALL_REQUIRES, license="Apache", cmdclass=cmdclass, diff --git a/python/cugraph/setuputils.py b/python/cugraph/setuputils.py index 09ae5dbd31f..af3ea1e83ef 100644 --- a/python/cugraph/setuputils.py +++ b/python/cugraph/setuputils.py @@ -245,3 +245,23 @@ def get_repo_cmake_info(names, file_path): def _get_repo_path(): python_dir = Path(__file__).resolve().parent return str(python_dir.parent.parent.absolute()) + + +def get_cuda_version_from_header(cuda_include_dir, delimiter=""): + + cuda_version = None + + with open(os.path.join(cuda_include_dir, "cuda.h"), encoding="utf-8") as f: + for line in f.readlines(): + if re.search(r"#define CUDA_VERSION ", line) is not None: + cuda_version = line + break + + if cuda_version is None: + raise TypeError("CUDA_VERSION not found in cuda.h") + cuda_version = int(cuda_version.split()[2]) + return "%d%s%d" % ( + cuda_version // 1000, + delimiter, + (cuda_version % 1000) // 10, + ) diff --git a/python/pylibcugraph/CMakeLists.txt b/python/pylibcugraph/CMakeLists.txt new file mode 100644 index 00000000000..030da9c3e38 --- /dev/null +++ b/python/pylibcugraph/CMakeLists.txt @@ -0,0 +1,69 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) + +set(pylibcugraph_version 22.08.00) + +include(../../fetch_rapids.cmake) + +project( + pylibcugraph-python + VERSION ${pylibcugraph_version} + LANGUAGES # TODO: Building Python extension modules via the python_extension_module requires the C + # language to be enabled here. The test project that is built in scikit-build to verify + # various linking options for the python library is hardcoded to build with C, so until + # that is fixed we need to keep C. + C CXX +) + +################################################################################ +# - User Options -------------------------------------------------------------- +option(FIND_CUGRAPH_CPP "Search for existing CUGRAPH C++ installations before defaulting to local files" + OFF +) + +# If the user requested it we attempt to find CUGRAPH. + +if(FIND_CUGRAPH_CPP) + message(STATUS "Trying to find the package") + find_package(cugraph ${cugraph_version} REQUIRED) +else() + set(cugraph_FOUND OFF) +endif() + +message(STATUS "check if it was found ${cugraph_FOUND}") + +if(NOT cugraph_FOUND) + # TODO: This will not be necessary once we upgrade to CMake 3.22, which will pull in the required + # languages for the C++ project even if this project does not require those languges. + include(rapids-cuda) + rapids_cuda_init_architectures(CUGRAPH) + enable_language(CUDA) + + # Since cugraph only enables CUDA optionally, we need to manually include the file that + # rapids_cuda_init_architectures relies on `project` including. + + include("${CMAKE_PROJECT_cugraph-python_INCLUDE}") + + add_subdirectory(../../cpp cugraph-cpp) + + install(TARGETS cugraph DESTINATION pylibcugraph/library) +endif() + + +include(rapids-cython) +rapids_cython_init() + +add_subdirectory(pylibcugraph) diff --git a/python/pylibcugraph/pylibcugraph/CMakeLists.txt b/python/pylibcugraph/pylibcugraph/CMakeLists.txt new file mode 100644 index 00000000000..c5ae32a0b2a --- /dev/null +++ b/python/pylibcugraph/pylibcugraph/CMakeLists.txt @@ -0,0 +1,42 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= +add_subdirectory(components) +add_subdirectory(raft/common) +set(cython_sources + bfs.pyx + core_number.pyx + eigenvector_centrality.pyx + graph_properties.pyx + graphs.pyx + hits.pyx + katz_centrality.pyx + node2vec.pyx + pagerank.pyx + resource_handle.pyx + sssp.pyx + triangle_count.pyx + uniform_neighbor_sample.pyx + utils.pyx +) +set(linked_libraries cugraph::cugraph;cugraph_c) + +rapids_cython_create_modules( + CXX + SOURCE_FILES "${cython_sources}" + LINKED_LIBRARIES ${linked_libraries} +) + +foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) + set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/library") +endforeach() diff --git a/python/pylibcugraph/pylibcugraph/components/CMakeLists.txt b/python/pylibcugraph/pylibcugraph/components/CMakeLists.txt new file mode 100644 index 00000000000..8f156c0e6d2 --- /dev/null +++ b/python/pylibcugraph/pylibcugraph/components/CMakeLists.txt @@ -0,0 +1,28 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +set(cython_sources + _connectivity.pyx +) +set(linked_libraries cugraph::cugraph) + +rapids_cython_create_modules( + CXX + SOURCE_FILES "${cython_sources}" + LINKED_LIBRARIES "${linked_libraries}" +) + +foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) + set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../library") +endforeach() diff --git a/python/pylibcugraph/pylibcugraph/raft/common/CMakeLists.txt b/python/pylibcugraph/pylibcugraph/raft/common/CMakeLists.txt new file mode 100644 index 00000000000..18d5e59c664 --- /dev/null +++ b/python/pylibcugraph/pylibcugraph/raft/common/CMakeLists.txt @@ -0,0 +1,29 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +set(cython_sources + cuda.pyx + handle.pyx +) +set(linked_libraries cugraph::cugraph) + +rapids_cython_create_modules( + CXX + SOURCE_FILES "${cython_sources}" + LINKED_LIBRARIES "${linked_libraries}" +) + +foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) + set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/../../library") +endforeach() diff --git a/python/pylibcugraph/pylibcugraph/utilities/api_tools.py b/python/pylibcugraph/pylibcugraph/utilities/api_tools.py index 0cee609c730..dfb646a0784 100644 --- a/python/pylibcugraph/pylibcugraph/utilities/api_tools.py +++ b/python/pylibcugraph/pylibcugraph/utilities/api_tools.py @@ -33,7 +33,7 @@ def experimental_warning_wrapper(obj): discovered and used. """ obj_type = type(obj) - if obj_type not in [type, types.FunctionType, types.BuiltinFunctionType]: + if not callable(obj): raise TypeError("obj must be a class or a function type, got " f"{obj_type}") @@ -102,7 +102,7 @@ def promoted_experimental_warning_wrapper(obj): have the experimental namespace. """ obj_type = type(obj) - if obj_type not in [type, types.FunctionType, types.BuiltinFunctionType]: + if not callable(obj): raise TypeError("obj must be a class or a function type, got " f"{obj_type}") @@ -154,7 +154,7 @@ def deprecated_warning_wrapper(obj): by a refactored version), prior to calling obj and returning its value. """ obj_type = type(obj) - if obj_type not in [type, types.FunctionType, types.BuiltinFunctionType]: + if not callable(obj): raise TypeError("obj must be a class or a function type, got " f"{obj_type}") diff --git a/python/pylibcugraph/pyproject.toml b/python/pylibcugraph/pyproject.toml new file mode 100644 index 00000000000..ac4538c41f7 --- /dev/null +++ b/python/pylibcugraph/pyproject.toml @@ -0,0 +1,12 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. + +[build-system] + +requires = [ + "wheel", + "setuptools", + "cython>=0.29,<0.30", + "scikit-build>=0.13.1", + "cmake>=3.20.1,!=3.23.0", + "ninja", +] diff --git a/python/pylibcugraph/setup.py b/python/pylibcugraph/setup.py index 40bce1c3b09..8ea4337407b 100644 --- a/python/pylibcugraph/setup.py +++ b/python/pylibcugraph/setup.py @@ -12,41 +12,16 @@ # limitations under the License. import os -import sys -import sysconfig import shutil -from setuptools import setup, find_packages, Command -from setuptools.extension import Extension -from setuputils import get_environment_option +from setuptools import find_packages, Command +from skbuild import setup -try: - from Cython.Distutils.build_ext import new_build_ext as build_ext -except ImportError: - from setuptools.command.build_ext import build_ext +from setuputils import get_environment_option import versioneer -from distutils.sysconfig import get_python_lib - - -CYTHON_FILES = ['pylibcugraph/**/*.pyx'] -UCX_HOME = get_environment_option("UCX_HOME") CUDA_HOME = get_environment_option('CUDA_HOME') -CONDA_PREFIX = get_environment_option('CONDA_PREFIX') - -conda_lib_dir = os.path.normpath(sys.prefix) + '/lib' -conda_include_dir = os.path.normpath(sys.prefix) + '/include' - -if CONDA_PREFIX: - conda_include_dir = CONDA_PREFIX + '/include' - conda_lib_dir = CONDA_PREFIX + '/lib' - -if not UCX_HOME: - UCX_HOME = CONDA_PREFIX if CONDA_PREFIX else os.sys.prefix - -ucx_include_dir = os.path.join(UCX_HOME, "include") -ucx_lib_dir = os.path.join(UCX_HOME, "lib") if not CUDA_HOME: path_to_cuda_gdb = shutil.which("cuda-gdb") @@ -64,15 +39,6 @@ "Invalid CUDA_HOME: " "directory does not exist: {CUDA_HOME}" ) -cuda_include_dir = os.path.join(CUDA_HOME, "include") -cuda_lib_dir = os.path.join(CUDA_HOME, "lib64") - -# Optional location of C++ build folder that can be configured by the user -libcugraph_path = get_environment_option('CUGRAPH_BUILD_PATH') - -if not libcugraph_path: - libcugraph_path = conda_lib_dir - class CleanCommand(Command): """Custom clean command to tidy up the project root.""" @@ -94,46 +60,15 @@ def run(self): os.system('rm -rf *.egg-info') os.system('find . -name "*.cpp" -type f -delete') os.system('find . -name "*.cpython*.so" -type f -delete') + os.system('rm -rf _skbuild') -cmdclass = dict() +cmdclass = versioneer.get_cmdclass() cmdclass.update(versioneer.get_cmdclass()) -cmdclass["build_ext"] = build_ext cmdclass["clean"] = CleanCommand -EXTENSIONS = [ - Extension("*", - sources=CYTHON_FILES, - include_dirs=[ - conda_include_dir, - ucx_include_dir, - "../../cpp/include", - "../../thirdparty/cub", - os.path.join(conda_include_dir, "libcudacxx"), - cuda_include_dir, - os.path.dirname(sysconfig.get_path("include")) - ], - library_dirs=[ - get_python_lib(), - conda_lib_dir, - libcugraph_path, - ucx_lib_dir, - cuda_lib_dir, - os.path.join(os.sys.prefix, "lib") - ], - libraries=['cudart', 'cusparse', 'cusolver', 'cugraph', 'nccl', - 'cugraph_c', 'cublas'], - language='c++', - extra_compile_args=['-std=c++17']) -] - -for e in EXTENSIONS: - e.cython_directives = dict( - profile=False, language_level=3, embedsignature=True - ) - setup(name='pylibcugraph', - description="pylibcugraph - GPU Graph Analytics", + description="pylibcuGraph - RAPIDS GPU Graph Analytics", version=versioneer.get_version(), classifiers=[ # "Development Status :: 4 - Beta", @@ -145,9 +80,11 @@ def run(self): ], # Include the separately-compiled shared library author="NVIDIA Corporation", - setup_requires=['cython'], - ext_modules=EXTENSIONS, + setup_requires=['Cython>=0.29,<0.30'], packages=find_packages(include=['pylibcugraph', 'pylibcugraph.*']), + package_data={ + key: ["*.pxd"] for key in find_packages(include=["pylibcugraph*"]) + }, license="Apache", cmdclass=cmdclass, zip_safe=False) diff --git a/python/pylibcugraph/setuputils.py b/python/pylibcugraph/setuputils.py index d2251a80af7..a808165f432 100644 --- a/python/pylibcugraph/setuputils.py +++ b/python/pylibcugraph/setuputils.py @@ -245,3 +245,23 @@ def get_repo_cmake_info(names, file_path): def _get_repo_path(): python_dir = Path(__file__).resolve().parent return str(python_dir.parent.parent.absolute()) + + +def get_cuda_version_from_header(cuda_include_dir, delimiter=""): + + cuda_version = None + + with open(os.path.join(cuda_include_dir, "cuda.h"), encoding="utf-8") as f: + for line in f.readlines(): + if re.search(r"#define CUDA_VERSION ", line) is not None: + cuda_version = line + break + + if cuda_version is None: + raise TypeError("CUDA_VERSION not found in cuda.h") + cuda_version = int(cuda_version.split()[2]) + return "%d%s%d" % ( + cuda_version // 1000, + delimiter, + (cuda_version % 1000) // 10, + )