### Install nx-cugraph Source: https://rapids.ai/nx-cugraph Install the nx-cugraph package using pip. The `--extra-index-url` is required to fetch packages from the NVIDIA PyPI. ```bash pip install nx-cugraph-cu13 --extra-index-url https://pypi.nvidia.com ``` -------------------------------- ### Install Polars with GPU Engine Source: https://rapids.ai/polars-gpu-engine Install Polars with the necessary GPU engine components and configure the NVIDIA PyPI index. ```bash pip install polars[gpu] --extra-index-url=https://pypi.nvidia.com ``` -------------------------------- ### Install RAPIDS with Conda Source: https://rapids.ai/ Installs the latest miniforge and then creates a Conda environment with RAPIDS 26.04, Python 3.14, and CUDA 13.1. ```bash wget "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" bash Miniforge3-$(uname)-$(uname -m).shCopy ``` ```bash conda create -n rapids-26.04 -c rapidsai -c conda-forge rapids=26.04 python=3.14 cuda-version=13.1Copy ``` -------------------------------- ### NetworkX Graph Creation and Betweenness Centrality Benchmark Source: https://rapids.ai/nx-cugraph This example demonstrates creating a graph from a Pandas DataFrame and measuring the execution time of the `betweenness_centrality` function on CPU and GPU. It requires NetworkX, Pandas, and the nx-cugraph backend. ```python import networkx as nx import pandas as pd url = "https://data.rapids.ai/cugraph/datasets/cit-Patents.csv" df = pd.read_csv(url, sep=" ", names=["src", "dst"], dtype="int32") G = nx.from_pandas_edgelist(df, source="src", target="dst") %time result = nx.betweenness_centrality(G, k=10) ``` ```shell user@machine:/# ipython demo.ipy CPU times: user 7min 36s, sys: 5.22 s, total: 7min 41s Wall time: 7min 41s ``` ```shell user@machine:/# NX_CUGRAPH_AUTOCONFIG=True ipython demo.ipy CPU times: user 4.14 s, sys: 1.13 s, total: 5.27 s Wall time: 5.32 s ``` -------------------------------- ### Install RAPIDS with pip Source: https://rapids.ai/ Installs RAPIDS libraries including cudf, dask-cudf, cuml, and cugraph from the NVIDIA PyPI index. ```bash pip install \ --extra-index-url=https://pypi.nvidia.com \ cudf-cu13==26.4.* \ dask-cudf-cu13==26.4.* \ cuml-cu13==26.4.* \ cugraph-cu13==26.4.*Copy ``` -------------------------------- ### Check CUDA Version Source: https://rapids.ai/ Checks the installed NVIDIA driver and CUDA version using the nvidia-smi command. ```bash nvidia-smiCopy ``` -------------------------------- ### Explicitly Enable cuML.accel in Python Code Source: https://rapids.ai/cuml-accel Import cuml.accel and call the install() function to explicitly enable GPU acceleration within your Python script if command-line flags cannot be used. ```python import cuml.accel cuml.accel.install() import sklearn ... ``` -------------------------------- ### RAPIDS Citation Guide (BibTeX) Source: https://rapids.ai/branding Use this BibTeX entry for citing RAPIDS in LaTeX publications. Ensure the URL is current. ```bibtex @Manual{ title = {RAPIDS: Libraries for End to End GPU Data Science}, author = {RAPIDS Development Team}, year = {2023}, url = {https://rapids.ai} } ``` -------------------------------- ### Explicitly Enable cuDF Pandas Accelerator Source: https://rapids.ai/cudf-pandas Import and install `cudf.pandas` explicitly in your Python code if command-line flags or magic commands are not suitable. Ensure this is done before importing pandas. ```python import cudf.pandas cudf.pandas.install() import pandas as pd ``` -------------------------------- ### Load cuML.accel Extension in IPython/Jupyter Source: https://rapids.ai/cuml-accel Use the %load_ext magic command to enable cuML acceleration within IPython or Jupyter Notebooks. Ensure scikit-learn is imported after loading the extension. ```python %load_ext cuml.accel import sklearn ... ``` -------------------------------- ### Enable nx-cugraph via Notebook Magic Command Source: https://rapids.ai/nx-cugraph In a Jupyter notebook environment, use the `%env` magic command to set the NX_CUGRAPH_AUTOCONFIG environment variable before importing NetworkX to enable GPU acceleration. ```python %env NX_CUGRAPH_AUTOCONFIG=True import networkx ``` -------------------------------- ### Verify cuDF Pandas Accelerator Initialization Source: https://rapids.ai/cudf-pandas After enabling `cudf.pandas`, importing pandas will load a magic module. This output confirms that the accelerator is active and shows the underlying fast (cuDF) and slow (pandas) implementations. ```python In [1]: %load_ext cudf.pandas In [2]: import pandas as pd In [3]: pd Out[3]: ``` -------------------------------- ### Run RandomForestClassifier on GPU Source: https://rapids.ai/cuml-accel Demonstrates how cuML.accel intercepts scikit-learn estimators to run them on the GPU. Load the extension, import necessary modules, create data, instantiate an estimator, and call fit. The fit operation will run on the GPU if the estimator is implemented in cuML. ```python In [1]: %load_ext cuml.accel In [2]: from sklearn.ensemble import RandomForestClassifier In [3]: from sklearn.datasets import make_classification In [4]: X, y = make_classification(n_samples=10000, n_features=20) In [5]: clf = RandomForestClassifier(n_estimators=100) In [6]: clf.fit(X, y) # Runs on GPU! Out[6]: RandomForestClassifier() ``` -------------------------------- ### Configure Custom GPU Engine in Polars Source: https://rapids.ai/polars-gpu-engine For advanced control, instantiate a `GPUEngine` object with specific configurations like device ID and error handling, then pass it to the `collect` method. ```python import polars as pl ldf = pl.LazyFrame({"a": [1.242, 1.535]}) gpu_engine = pl.GPUEngine( device=0, raise_on_fail=True, ) print( ldf.select( pl.col("a").round(1) ).collect(engine=gpu_engine) ) ``` -------------------------------- ### Accelerate Python Script with cuML.accel Source: https://rapids.ai/cuml-accel Execute a Python script with GPU acceleration enabled by using the -m cuml.accel flag from the command line. ```bash python -m cuml.accel script.py ``` -------------------------------- ### Profile GPU and CPU Execution with %%cuml.accel.profile Source: https://rapids.ai/cuml-accel Utilize the %%cuml.accel.profile cell magic to analyze the performance of estimator operations, providing a breakdown of GPU and CPU calls and time. ```python In [8]: %%cuml.accel.profile ...: clf.fit(X, y) ...: ...: ``` -------------------------------- ### Enable cuDF Pandas Accelerator in IPython/Jupyter Source: https://rapids.ai/cudf-pandas Use the `%load_ext` magic command in IPython or Jupyter Notebooks to enable the cuDF pandas accelerator before importing pandas. ```python %load_ext cudf.pandas import pandas as pd ``` -------------------------------- ### Enable cuDF Pandas Accelerator in Python Scripts Source: https://rapids.ai/cudf-pandas Run a Python script with the `cudf.pandas` module flag to enable GPU acceleration for pandas operations. ```bash python -m cudf.pandas script.py ``` -------------------------------- ### Verify Estimator is a Proxy with is_proxy Source: https://rapids.ai/cuml-accel Use the is_proxy function from cuml.accel to confirm if an estimator has been replaced by a GPU-accelerated proxy. ```python In [7]: from cuml.accel import is_proxy In [8]: is_proxy(clf) Out[8]: True ``` -------------------------------- ### Enable nx-cugraph via Shell Environment Variable Source: https://rapids.ai/nx-cugraph To enable GPU acceleration for NetworkX scripts run from the shell, set the NX_CUGRAPH_AUTOCONFIG environment variable before executing your Python script. ```bash NX_CUGRAPH_AUTOCONFIG=True python my_networkx_script.py ``` -------------------------------- ### Use Default GPU Engine in Polars Source: https://rapids.ai/polars-gpu-engine Materialize a Polars LazyFrame into a DataFrame using the default GPU engine configuration by passing `engine="gpu"` to the `collect` method. ```python import polars as pl ldf = pl.LazyFrame({"a": [1.242, 1.535]}) print( ldf.select( pl.col("a").round(1) ).collect(engine="gpu") ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.