From de6b33b57425d3e7200c9e9ce0e72d177815651d Mon Sep 17 00:00:00 2001 From: James Lamb Date: Wed, 8 Jan 2025 12:45:49 -0600 Subject: [PATCH 1/4] pylibcugraph: declare cupy dependency --- conda/recipes/pylibcugraph/meta.yaml | 3 ++- dependencies.yaml | 1 + python/pylibcugraph/pyproject.toml | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/conda/recipes/pylibcugraph/meta.yaml b/conda/recipes/pylibcugraph/meta.yaml index 54d29a68d91..34c57f682ef 100644 --- a/conda/recipes/pylibcugraph/meta.yaml +++ b/conda/recipes/pylibcugraph/meta.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2023-2024, NVIDIA CORPORATION. +# Copyright (c) 2023-2025, NVIDIA CORPORATION. {% set version = environ['RAPIDS_PACKAGE_VERSION'].lstrip('v') + environ.get('VERSION_SUFFIX', '') %} {% set minor_version = version.split('.')[0] + '.' + version.split('.')[1] %} @@ -74,6 +74,7 @@ requirements: {% else %} - cuda-cudart {% endif %} + - cupy >=12.0.0 - libcugraph ={{ version }} - pylibraft ={{ minor_version }} - python diff --git a/dependencies.yaml b/dependencies.yaml index e1a8cc065c7..e5f0d73dfcb 100755 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -138,6 +138,7 @@ files: table: project includes: - cuda_wheels + - depends_on_cupy - depends_on_pylibraft - depends_on_rmm py_test_pylibcugraph: diff --git a/python/pylibcugraph/pyproject.toml b/python/pylibcugraph/pyproject.toml index 72a5e19c702..32dc0041acd 100644 --- a/python/pylibcugraph/pyproject.toml +++ b/python/pylibcugraph/pyproject.toml @@ -23,6 +23,7 @@ authors = [ license = { text = "Apache 2.0" } requires-python = ">=3.10" dependencies = [ + "cupy-cuda11x>=12.0.0", "nvidia-cublas", "nvidia-curand", "nvidia-cusolver", From 4a854b5a203a50beb24db7655ae6bad35eb6dfcb Mon Sep 17 00:00:00 2001 From: James Lamb Date: Thu, 9 Jan 2025 15:48:01 -0600 Subject: [PATCH 2/4] make numpy and cupy hard dependencies --- conda/recipes/pylibcugraph/meta.yaml | 1 + dependencies.yaml | 22 +++++++++---------- python/cugraph-service/server/pyproject.toml | 1 - python/cugraph/pyproject.toml | 2 -- python/pylibcugraph/pylibcugraph/bfs.pyx | 9 +++----- python/pylibcugraph/pylibcugraph/node2vec.pyx | 12 +++------- python/pylibcugraph/pylibcugraph/pagerank.pyx | 19 ++++------------ .../pylibcugraph/personalized_pagerank.pyx | 19 ++++------------ python/pylibcugraph/pylibcugraph/sssp.pyx | 19 ++++------------ python/pylibcugraph/pyproject.toml | 1 + 10 files changed, 31 insertions(+), 74 deletions(-) diff --git a/conda/recipes/pylibcugraph/meta.yaml b/conda/recipes/pylibcugraph/meta.yaml index 34c57f682ef..e8a0286d2b8 100644 --- a/conda/recipes/pylibcugraph/meta.yaml +++ b/conda/recipes/pylibcugraph/meta.yaml @@ -76,6 +76,7 @@ requirements: {% endif %} - cupy >=12.0.0 - libcugraph ={{ version }} + - numpy>=1.23,<3.0a0 - pylibraft ={{ minor_version }} - python - rmm ={{ minor_version }} diff --git a/dependencies.yaml b/dependencies.yaml index d58cf0ea7ca..8cdbf477b54 100755 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -18,6 +18,7 @@ files: - depends_on_libcudf - depends_on_libraft - depends_on_librmm + - depends_on_numpy - depends_on_pylibraft - depends_on_pylibwholegraph - depends_on_pytorch @@ -33,7 +34,6 @@ files: - test_notebook - test_python_common - test_python_cugraph - - test_python_pylibcugraph checks: output: none includes: @@ -64,12 +64,12 @@ files: includes: - cuda_version - depends_on_cudf + - depends_on_numpy - depends_on_pylibwholegraph - depends_on_pytorch - py_version - test_python_common - test_python_cugraph - - test_python_pylibcugraph py_build_cugraph: output: pyproject pyproject_dir: python/cugraph @@ -142,6 +142,7 @@ files: includes: - cuda_wheels - depends_on_cupy + - depends_on_numpy - depends_on_pylibraft - depends_on_rmm py_test_pylibcugraph: @@ -152,8 +153,8 @@ files: key: test includes: - depends_on_cudf + - depends_on_numpy - test_python_common - - test_python_pylibcugraph py_build_cugraph_service_client: output: pyproject pyproject_dir: python/cugraph-service/client @@ -189,6 +190,7 @@ files: - depends_on_cupy - depends_on_dask_cuda - depends_on_dask_cudf + - depends_on_numpy - depends_on_rmm - depends_on_ucx_py - python_run_cugraph_service_server @@ -399,7 +401,6 @@ dependencies: packages: - &dask rapids-dask-dependency==25.2.*,>=0.0.0a0 - &numba numba>=0.57 - - &numpy numpy>=1.23,<3.0a0 - output_types: conda packages: - aiohttp @@ -433,7 +434,6 @@ dependencies: packages: - *dask - *numba - - *numpy - *thrift test_cpp: common: @@ -463,17 +463,11 @@ dependencies: packages: - certifi - networkx>=2.5.1 - - *numpy - python-louvain - scikit-learn>=0.23.1 - output_types: [conda] packages: - *thrift - test_python_pylibcugraph: - common: - - output_types: [conda, pyproject] - packages: - - *numpy depends_on_cugraph: common: @@ -766,6 +760,12 @@ dependencies: - cupy-cuda11x>=12.0.0 - {matrix: null, packages: *cupy_packages_cu11} + depends_on_numpy: + common: + - output_types: [conda, pyproject, requirements] + packages: + - numpy>=1.23,<3.0a0 + depends_on_ucx_py: common: - output_types: conda diff --git a/python/cugraph-service/server/pyproject.toml b/python/cugraph-service/server/pyproject.toml index 29ee41854f8..38a1be740a4 100644 --- a/python/cugraph-service/server/pyproject.toml +++ b/python/cugraph-service/server/pyproject.toml @@ -48,7 +48,6 @@ cugraph-service-server = "cugraph_service_server.__main__:main" test = [ "certifi", "networkx>=2.5.1", - "numpy>=1.23,<3.0a0", "pandas", "pytest", "pytest-benchmark", diff --git a/python/cugraph/pyproject.toml b/python/cugraph/pyproject.toml index 8fa3a0938e8..15ead1cc3f9 100644 --- a/python/cugraph/pyproject.toml +++ b/python/cugraph/pyproject.toml @@ -30,7 +30,6 @@ dependencies = [ "dask-cudf==25.2.*,>=0.0.0a0", "fsspec[http]>=0.6.0", "numba>=0.57", - "numpy>=1.23,<3.0a0", "pylibcugraph==25.2.*,>=0.0.0a0", "raft-dask==25.2.*,>=0.0.0a0", "rapids-dask-dependency==25.2.*,>=0.0.0a0", @@ -49,7 +48,6 @@ classifiers = [ test = [ "certifi", "networkx>=2.5.1", - "numpy>=1.23,<3.0a0", "pandas", "pylibwholegraph==25.2.*,>=0.0.0a0", "pytest", diff --git a/python/pylibcugraph/pylibcugraph/bfs.pyx b/python/pylibcugraph/pylibcugraph/bfs.pyx index b92afcfd7db..e6a22109b9e 100644 --- a/python/pylibcugraph/pylibcugraph/bfs.pyx +++ b/python/pylibcugraph/pylibcugraph/bfs.pyx @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2024, NVIDIA CORPORATION. +# Copyright (c) 2022-2025, 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 @@ -14,6 +14,8 @@ # Have cython use python 3 syntax # cython: language_level = 3 +import cupy + from libc.stdint cimport uintptr_t from libc.stdint cimport int32_t from libc.limits cimport INT_MAX @@ -141,11 +143,6 @@ def bfs(ResourceHandle handle, _GPUGraph graph, >>> }) """ - try: - import cupy - except ModuleNotFoundError: - raise RuntimeError("bfs requires the cupy package, which could not " - "be imported") assert_CAI_type(sources, "sources") if depth_limit <= 0: diff --git a/python/pylibcugraph/pylibcugraph/node2vec.pyx b/python/pylibcugraph/pylibcugraph/node2vec.pyx index 0e0fd73e6c8..e81afb58061 100644 --- a/python/pylibcugraph/pylibcugraph/node2vec.pyx +++ b/python/pylibcugraph/pylibcugraph/node2vec.pyx @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2024, NVIDIA CORPORATION. +# Copyright (c) 2022-2025, 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 @@ -14,6 +14,8 @@ # Have cython use python 3 syntax # cython: language_level = 3 +import cupy + from libc.stdint cimport uintptr_t from pylibcugraph._cugraph_c.types cimport ( @@ -124,14 +126,6 @@ def node2vec(ResourceHandle resource_handle, """ - # FIXME: import these modules here for now until a better pattern can be - # used for optional imports (perhaps 'import_optional()' from cugraph), or - # these are made hard dependencies. - try: - import cupy - except ModuleNotFoundError: - raise RuntimeError("node2vec requires the cupy package, which could not " - "be imported") assert_CAI_type(seed_array, "seed_array") cdef cugraph_resource_handle_t* c_resource_handle_ptr = \ diff --git a/python/pylibcugraph/pylibcugraph/pagerank.pyx b/python/pylibcugraph/pylibcugraph/pagerank.pyx index bcb8474ddfa..961e191e054 100644 --- a/python/pylibcugraph/pylibcugraph/pagerank.pyx +++ b/python/pylibcugraph/pylibcugraph/pagerank.pyx @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2024, NVIDIA CORPORATION. +# Copyright (c) 2022-2025, 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 @@ -14,6 +14,9 @@ # Have cython use python 3 syntax # cython: language_level = 3 +import cupy +import numpy + from pylibcugraph._cugraph_c.types cimport ( bool_t, ) @@ -167,20 +170,6 @@ def pagerank(ResourceHandle resource_handle, array([0.11615585, 0.21488841, 0.2988108 , 0.3701449 ], dtype=float32) """ - # FIXME: import these modules here for now until a better pattern can be - # used for optional imports (perhaps 'import_optional()' from cugraph), or - # these are made hard dependencies. - try: - import cupy - except ModuleNotFoundError: - raise RuntimeError("pagerank requires the cupy package, which could " - "not be imported") - try: - import numpy - except ModuleNotFoundError: - raise RuntimeError("pagerank requires the numpy package, which could " - "not be imported") - cdef cugraph_type_erased_device_array_view_t* \ initial_guess_vertices_view_ptr = \ create_cugraph_type_erased_device_array_view_from_py_obj( diff --git a/python/pylibcugraph/pylibcugraph/personalized_pagerank.pyx b/python/pylibcugraph/pylibcugraph/personalized_pagerank.pyx index 209d4054491..1926f41b13d 100644 --- a/python/pylibcugraph/pylibcugraph/personalized_pagerank.pyx +++ b/python/pylibcugraph/pylibcugraph/personalized_pagerank.pyx @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2024, NVIDIA CORPORATION. +# Copyright (c) 2022-2025, 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 @@ -14,6 +14,9 @@ # Have cython use python 3 syntax # cython: language_level = 3 +import cupy +import numpy + from pylibcugraph._cugraph_c.types cimport ( bool_t, ) @@ -177,20 +180,6 @@ def personalized_pagerank(ResourceHandle resource_handle, array([0.00446455, 0.00379487, 0.53607565, 0.45566472 ], dtype=float32) """ - # FIXME: import these modules here for now until a better pattern can be - # used for optional imports (perhaps 'import_optional()' from cugraph), or - # these are made hard dependencies. - try: - import cupy - except ModuleNotFoundError: - raise RuntimeError("pagerank requires the cupy package, which could " - "not be imported") - try: - import numpy - except ModuleNotFoundError: - raise RuntimeError("pagerank requires the numpy package, which could " - "not be imported") - cdef cugraph_type_erased_device_array_view_t* \ initial_guess_vertices_view_ptr = \ create_cugraph_type_erased_device_array_view_from_py_obj( diff --git a/python/pylibcugraph/pylibcugraph/sssp.pyx b/python/pylibcugraph/pylibcugraph/sssp.pyx index 7e40a801e94..2eff824d4d3 100644 --- a/python/pylibcugraph/pylibcugraph/sssp.pyx +++ b/python/pylibcugraph/pylibcugraph/sssp.pyx @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2024, NVIDIA CORPORATION. +# Copyright (c) 2022-2025, 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 @@ -14,6 +14,9 @@ # Have cython use python 3 syntax # cython: language_level = 3 +import cupy +import numpy + from pylibcugraph._cugraph_c.types cimport ( bool_t, ) @@ -124,20 +127,6 @@ def sssp(ResourceHandle resource_handle, array([-1, -1, 1, 2], dtype=int32) """ - # FIXME: import these modules here for now until a better pattern can be - # used for optional imports (perhaps 'import_optional()' from cugraph), or - # these are made hard dependencies. - try: - import cupy - except ModuleNotFoundError: - raise RuntimeError("sssp requires the cupy package, which could not " - "be imported") - try: - import numpy - except ModuleNotFoundError: - raise RuntimeError("sssp requires the numpy package, which could not " - "be imported") - if compute_predecessors is False: raise ValueError("compute_predecessors must be True for the current " "release.") diff --git a/python/pylibcugraph/pyproject.toml b/python/pylibcugraph/pyproject.toml index 32dc0041acd..cd98e37d327 100644 --- a/python/pylibcugraph/pyproject.toml +++ b/python/pylibcugraph/pyproject.toml @@ -24,6 +24,7 @@ license = { text = "Apache 2.0" } requires-python = ">=3.10" dependencies = [ "cupy-cuda11x>=12.0.0", + "numpy>=1.23,<3.0a0", "nvidia-cublas", "nvidia-curand", "nvidia-cusolver", From 67d75aa77529c7683d8a29999685f3303e417fc6 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Fri, 10 Jan 2025 09:00:07 -0600 Subject: [PATCH 3/4] restore numpy dependency for cugraph and cugraph-service-server --- dependencies.yaml | 2 ++ python/cugraph-service/server/pyproject.toml | 1 + python/cugraph/pyproject.toml | 1 + 3 files changed, 4 insertions(+) diff --git a/dependencies.yaml b/dependencies.yaml index 8cdbf477b54..20471c9148c 100755 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -100,6 +100,7 @@ files: - depends_on_cupy - depends_on_dask_cuda - depends_on_dask_cudf + - depends_on_numpy - depends_on_pylibcugraph - depends_on_raft_dask - depends_on_rmm @@ -176,6 +177,7 @@ files: extras: table: build-system includes: + - depends_on_numpy - python_build_rapids - python_build_wheel py_run_cugraph_service_server: diff --git a/python/cugraph-service/server/pyproject.toml b/python/cugraph-service/server/pyproject.toml index 38a1be740a4..8e8f6d85a9b 100644 --- a/python/cugraph-service/server/pyproject.toml +++ b/python/cugraph-service/server/pyproject.toml @@ -3,6 +3,7 @@ [build-system] requires = [ + "numpy>=1.23,<3.0a0", "rapids-build-backend>=0.3.1,<0.4.0.dev0", "setuptools>=61.0.0", "wheel", diff --git a/python/cugraph/pyproject.toml b/python/cugraph/pyproject.toml index 15ead1cc3f9..d1a3f7739ce 100644 --- a/python/cugraph/pyproject.toml +++ b/python/cugraph/pyproject.toml @@ -30,6 +30,7 @@ dependencies = [ "dask-cudf==25.2.*,>=0.0.0a0", "fsspec[http]>=0.6.0", "numba>=0.57", + "numpy>=1.23,<3.0a0", "pylibcugraph==25.2.*,>=0.0.0a0", "raft-dask==25.2.*,>=0.0.0a0", "rapids-dask-dependency==25.2.*,>=0.0.0a0", From d400dc8e796ccd2a6e1e9a819a12aa1bcb8800d9 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Fri, 10 Jan 2025 09:02:09 -0600 Subject: [PATCH 4/4] fix cugraph test dependencies --- dependencies.yaml | 1 + python/cugraph/pyproject.toml | 1 + 2 files changed, 2 insertions(+) diff --git a/dependencies.yaml b/dependencies.yaml index 20471c9148c..3d94571d1ae 100755 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -113,6 +113,7 @@ files: table: project.optional-dependencies key: test includes: + - depends_on_numpy - depends_on_pylibwholegraph - test_python_common - test_python_cugraph diff --git a/python/cugraph/pyproject.toml b/python/cugraph/pyproject.toml index d1a3f7739ce..8fa3a0938e8 100644 --- a/python/cugraph/pyproject.toml +++ b/python/cugraph/pyproject.toml @@ -49,6 +49,7 @@ classifiers = [ test = [ "certifi", "networkx>=2.5.1", + "numpy>=1.23,<3.0a0", "pandas", "pylibwholegraph==25.2.*,>=0.0.0a0", "pytest",