nx-cugraph - GPU Backend for NetworkX
Description
nx-cugraph is a backend to NetworkX to run algorithms with zero code change GPU acceleration.
🔍 Try it in Google Colab!
System Requirements
- GPU: NVIDIA Volta architecture or later, with compute capability 7.0+
- CUDA Version: 12.2 or higher
- Python Version: 3.11 - 3.13
- NetworkX Version: minimum 3.2 (version 3.5 or higher recommended)
Note: nx-cugraph is supported only on Linux
See RAPIDS System Requirements for detailed information on OS and Versions.
Installation
nx-cugraph can be installed using either conda or pip with the following commands.
conda
nx-cugraph can be installed with conda (via Miniforge) from the rapidsai channel.
# CUDA 13
conda install -c rapidsai -c conda-forge nx-cugraph cuda-version=13.3
# CUDA 12
conda install -c rapidsai -c conda-forge nx-cugraph cuda-verison=12.9
We also provide nightly Conda packages built from the HEAD of our latest development branch.
# CUDA 13
conda install -c rapidsai-nightly -c conda-forge nx-cugraph cuda-version=13.3
# CUDA 12
conda install -c rapidsai-nightly -c conda-forge nx-cugraph cuda-verison=12.9
pip
nx-cugraph can be installed via pip from the NVIDIA Python Package Index.
For CUDA 13.x:
Latest nightly version
python -m pip install nx-cugraph-cu13 --extra-index-url https://pypi.anaconda.org/rapidsai-wheels-nightly/simple
Latest stable version
python -m pip install nx-cugraph-cu13 --extra-index-url https://pypi.nvidia.com
Notes:
- Try out the RAPIDS Install Selector Tool to install other RAPIDS packages.
For CUDA 12.x:
Latest nightly version
python -m pip install nx-cugraph-cu12 --extra-index-url https://pypi.anaconda.org/rapidsai-wheels-nightly/simple
Latest stable version
python -m pip install nx-cugraph-cu12 --extra-index-url https://pypi.nvidia.com
Notes:
- Try out the RAPIDS Install Selector Tool to install other RAPIDS packages.
Enabling nx-cugraph
NetworkX will use nx-cugraph as the graph analytics backend if any of the following are used:
NX_CUGRAPH_AUTOCONFIG environment variable.
By setting NX_CUGRAPH_AUTOCONFIG=True, NetworkX will automatically dispatch algorithm calls to nx-cugraph (if the backend is supported). This allows users to GPU accelerate their code with zero code change.
Read more on Networkx Backends and How They Work.
Example:
bash> NX_CUGRAPH_AUTOCONFIG=True python my_networkx_script.py
backend= keyword argument
To explicitly specify a particular backend for an API, use the backend=
keyword argument. This argument takes precedence over the
NX_CUGRAPH_AUTOCONFIG environment variable. This requires anyone
running code that uses the backend= keyword argument to have the specified
backend installed.
Example:
nx.betweenness_centrality(cit_patents_graph, k=k, backend="cugraph")
Type-based dispatching
NetworkX also supports automatically dispatching to backends associated with
specific graph types. Like the backend= keyword argument example above, this
requires the user to write code for a specific backend, and therefore requires
the backend to be installed, but has the advantage of ensuring a particular
behavior without the potential for runtime conversions.
To use type-based dispatching with nx-cugraph, the user must import the backend directly in their code to access the utilities provided to create a Graph instance specifically for the nx-cugraph backend.
Example:
import networkx as nx
import nx_cugraph as nxcg
G = nx.Graph()
...
nxcg_G = nxcg.from_networkx(G) # conversion happens once here
nx.betweenness_centrality(nxcg_G, k=1000) # nxcg Graph type causes cugraph backend
# to be used, no conversion necessary
Supported Algorithms
The nx-cugraph backend to NetworkX connects pylibcugraph (cuGraph's low-level python interface to its CUDA-based graph analytics library) and CuPy (a GPU-accelerated array library) to NetworkX's familiar and easy-to-use API.
Below is the list of algorithms that are currently supported in nx-cugraph.
Algorithms
bipartite ├─ centrality │ └─ betweenness_centrality ├─ generators │ └─ complete_bipartite_graph └─ matrix ├─ biadjacency_matrix └─ from_biadjacency_matrix centrality ├─ betweenness │ ├─ betweenness_centrality │ └─ edge_betweenness_centrality ├─ degree_alg │ ├─ degree_centrality │ ├─ in_degree_centrality │ └─ out_degree_centrality ├─ eigenvector │ └─ eigenvector_centrality └─ katz └─ katz_centrality cluster ├─ average_clustering ├─ clustering ├─ transitivity └─ triangles community ├─ leiden │ └─ leiden_communities └─ louvain └─ louvain_communities components ├─ connected │ ├─ connected_components │ ├─ is_connected │ ├─ node_connected_component │ └─ number_connected_components └─ weakly_connected ├─ is_weakly_connected ├─ number_weakly_connected_components └─ weakly_connected_components core ├─ core_number └─ k_truss dag ├─ ancestors └─ descendants isolate ├─ is_isolate ├─ isolates └─ number_of_isolates link_analysis ├─ hits_alg │ └─ hits └─ pagerank_alg └─ pagerank link_prediction └─ jaccard_coefficient lowest_common_ancestors └─ lowest_common_ancestor operators └─ unary ├─ complement └─ reverse reciprocity ├─ overall_reciprocity └─ reciprocity shortest_paths ├─ generic │ ├─ has_path │ ├─ shortest_path │ └─ shortest_path_length ├─ unweighted │ ├─ all_pairs_shortest_path │ ├─ all_pairs_shortest_path_length │ ├─ bidirectional_shortest_path │ ├─ single_source_shortest_path │ ├─ single_source_shortest_path_length │ ├─ single_target_shortest_path │ └─ single_target_shortest_path_length └─ weighted ├─ all_pairs_bellman_ford_path ├─ all_pairs_bellman_ford_path_length ├─ all_pairs_dijkstra ├─ all_pairs_dijkstra_path ├─ all_pairs_dijkstra_path_length ├─ bellman_ford_path ├─ bellman_ford_path_length ├─ dijkstra_path ├─ dijkstra_path_length ├─ single_source_bellman_ford ├─ single_source_bellman_ford_path ├─ single_source_bellman_ford_path_length ├─ single_source_dijkstra ├─ single_source_dijkstra_path └─ single_source_dijkstra_path_length tournament └─ tournament_matrix traversal └─ breadth_first_search ├─ bfs_edges ├─ bfs_layers ├─ bfs_predecessors ├─ bfs_successors ├─ bfs_tree ├─ descendants_at_distance └─ generic_bfs_edges tree └─ recognition ├─ is_arborescence ├─ is_branching ├─ is_forest └─ is_tree
Generators
classic ├─ barbell_graph ├─ circular_ladder_graph ├─ complete_graph ├─ complete_multipartite_graph ├─ cycle_graph ├─ empty_graph ├─ ladder_graph ├─ lollipop_graph ├─ null_graph ├─ path_graph ├─ star_graph ├─ tadpole_graph ├─ trivial_graph ├─ turan_graph └─ wheel_graph community └─ caveman_graph ego └─ ego_graph small ├─ bull_graph ├─ chvatal_graph ├─ cubical_graph ├─ desargues_graph ├─ diamond_graph ├─ dodecahedral_graph ├─ frucht_graph ├─ heawood_graph ├─ house_graph ├─ house_x_graph ├─ icosahedral_graph ├─ krackhardt_kite_graph ├─ moebius_kantor_graph ├─ octahedral_graph ├─ pappus_graph ├─ petersen_graph ├─ sedgewick_maze_graph ├─ tetrahedral_graph ├─ truncated_cube_graph ├─ truncated_tetrahedron_graph └─ tutte_graph social ├─ davis_southern_women_graph ├─ florentine_families_graph ├─ karate_club_graph └─ les_miserables_graph
Other
classes └─ function ├─ is_negatively_weighted └─ number_of_selfloops convert ├─ from_dict_of_lists └─ to_dict_of_lists convert_matrix ├─ from_pandas_edgelist ├─ from_scipy_sparse_array ├─ to_numpy_array └─ to_scipy_sparse_array drawing └─ layout └─ forceatlas2_layout linalg └─ graphmatrix └─ adjacency_matrix relabel ├─ convert_node_labels_to_integers └─ relabel_nodes
To request nx-cugraph backend support for a NetworkX API that is not listed above, file an issue.
Contributing
If you would like to contribute to nx-cugraph, refer to the Contributing Guide
Release files for nx-cugraph-cu12 26.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nx_cugraph_cu12-26.8.0-py3-none-any.whl | Python 3 | none | any | Details |
Release files / nx_cugraph_cu12-26.8.0-py3-none-any.whl
| Download URL | nx_cugraph_cu12-26.8.0-py3-none-any.whl |
|---|---|
| Size | 153.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a58d1c71e908a99e145aac0a5338abdcd07fd0f0e772d636c040516fd3953d48
|
|
BLAKE2b-256 checksum How to use checksums |
94858381cf3278e38655c52c39fab285f48d4bf8ad574a5b4d28a345a59e5037
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|