• <xmp id="om0om">
  • <table id="om0om"><noscript id="om0om"></noscript></table>
  • 3 月 19 日下午 2 點,鎖定 NVIDIA AI 網絡中文專場。立即注冊觀看
    數據科學

    NVIDIA RAPIDS 24.10 版本發布零代碼修改加速 NetworkX 和 UMAP 及 cuDF-Pandas 新功能

    RAPIDS v24.10 版本 在為數據科學家和開發者提供無縫用戶體驗方面又向前邁出了一步。這篇博文重點介紹了以下新功能:

    • 零代碼更改加速的 NetworkX 現已正式推出(GA)
    • Polars GPU 引擎 (公測版)
    • 將 UMAP 引入大于 GPU 的內存數據集
    • 改進了 cuDF pandas 與 NumPy 和 PyArrow 的兼容性。
    • 將 GPU 集成到基于 GitHub 的 CI 系統的指南
    • RAPIDS 范圍內對 Python 3.12 和 NumPy 2.x 的支持

    零代碼更改加速 NetworkX?

    從 NetworkX 3.4 開始,由 RAPIDS cuGraph 加速的 NetworkX 現已在 24.10 版本中正式發布。該版本增加了 GPU 加速的圖形創建、新的用戶體驗和 擴展文檔

    加速圖形構建可實現 NetworkX 工作流程的全面端到端加速,對于 CPU 和 GPU 之間的轉換可能會降低性能的大型圖形工作流程尤其重要。

    現在,通過將 NX_CUGRAPH_AUTOCONFIG 環境變量設置為 True,可以啟用完整的端到端加速 NetworkX 體驗。

    %env NX_CURGAPH_AUTOCONFIG=True
     
    import pandas as pd
    import networkx as nx
     
    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)

    端到端加速使使用 betweenness centrality、PageRank 等算法的工作流程能夠在更大的圖形上體驗高達 10 倍、50 倍甚至 500 倍的加速。

    Horizontal bar chart showing PageRank algorithm used to compute values for a citation graph of U.S. patents (4M nodes, 16M edges) is 70x faster than NetworkX on CPU.
    圖 1 、在美國專利引文圖(4M 個節點,16M 個邊緣)上運行的 PageRank 算法比 CPU 上的 NetworkX 快 70 倍;軟件:NetworkX 3.4.1,cuGraph/nx-cugraph 24.10;GPU:NVIDIA A100 80GB;CPU:Intel Xeon w9-3495X(56 核)250GB
    Horizontal bar chart showing betweenness centrality algorithm used to compute values for the Live Journal social network (5M nodes, 69M edges, k=100) is 485x faster than NetworkX on CPU.
    圖 2 、當樣本數(k)設置為 100 時,在 Live Journal 社交網絡(5M 個節點,69M 條邊)上運行的間隔中心算法的速度比 CPU 上的 NetworkX 快 485 倍。SW:NetworkX 3.4.1,cuGraph/nx-cugraph 24.10;GPU:NVIDIA A100 80GB;CPU:Intel Xeon w9-3495X(56 核)250GB

    您可以在 文檔中 詳細了解由 cuGraph 加速的 NetworkX,并在 此處 探索上述基準測試的代碼。

    零代碼更改加速 Polars (公測版)

    9 月,由 cuDF 提供支持的 Polars GPU 引擎發布了公開測試版。在 Polars 中提供了 GPU 支持,用戶可以訪問工作流的速度最高可提升 13 倍,且無需更改代碼,相比在 CPU 上運行。

    A bar chart comparing query execution times between Polars CPU and Polars GPU engines across 22 queries. The y-axis shows execution time in seconds from 0 to 45. Most GPU bars are significantly shorter than their CPU counterparts, indicating faster performance. The title states "Accelerate Polars workflows up to 13x”. Additional notes provide benchmark details including scale factor, hardware specs, and a disclaimer about comparability to TPC-H results.
    圖 3. 這是 PDS-H 基準測試中對一組 22 個查詢實現的四項最佳加速。與 CPU 相比,由 RAPIDS cuDF 驅動的 Polars GPU 引擎可在處理涉及許多復雜分組和連接操作的查詢時提供高達 13 倍的速度提升。PDS-H 基準測試擴展系數 80 | GPU:NVIDIA H100 | CPU:Intel Xeon W9-3495X (Sapphire Rapids) | 存儲:本地 NVMe。注意:PDS-H 源自 TPC-H,但這些結果無法與 TPC-H 結果進行比較。

    用戶可以直接在 Polars Lazy API 中構建,將 Polars 配置為在觸發計算時使用 GPU,將 `engine` 關鍵字配置為 `collect`。

    import polars as pl
     
    df = pl.LazyFrame({"a": [1.242, 1.535]})
    q = df.select(pl.col("a").round(1))
    result = q.collect(engine="gpu")

    如需了解詳情,請閱讀 NVIDIA Polars 公告博客或深入了解 Polars GPU 支持文檔 。或者,直接進入 Google Colab notebook 進行試用。

    將 UMAP 引入大于 GPU 的內存數據集?

    從 v24.10 開始,cuML 的 UMAP 算法現在支持處理大于 GPU 內存的數據集,而這在早期版本中可能會導致內存不足錯誤。通過使用 新的分批式近似近鄰算法 并可選地將完整數據集存儲在 CPU 內存中,我們能夠構建近似 KNN 圖形,同時在任何給定時間僅處理 GPU 上的數據子集。

    用戶可以將新的 nnd_n_clusters 關鍵字設置為大于 1 的任何值(默認值),并(如有必要)將 data_on_host=True 關鍵字傳遞至 fitfit_transform,從而利用此新的可選功能。

    from cuml.manifold import UMAP
    import numpy as np
     
    # Generate synthetic data using numpy (random float32 matrix)
    X = np.random.rand(n_samples, n_features).astype(np.float32)
     
    # UMAP parameters
    num_clusters = 4  # Number of clusters for NN Descent batching, 1 means no clustering
    data_on_host = True  # Whether the data is stored on the host (CPU)
     
    # UMAP model configuration
    reducer = UMAP(
        n_neighbors=10,
        min_dist=0.01,
        build_algo="nn_descent",
        build_kwds={"nnd_n_clusters": num_clusters},
    )
     
    # Fit and transform the data
    embeddings = reducer.fit_transform(X, data_on_host=data_on_host)

    用戶可以從 n_clusters(例如 4) 的初始值開始,并根據需要增加該值,以管理 GPU 內存使用情況。設置值過高可能會因圖形構建的多次迭代而導致性能開銷,因此最好根據數據集的大小和可用的 GPU 內存來尋求平衡。

    改進了 cuDF pandas 生態系統兼容性?

    改進了代碼兼容性?

    cuDF 的 pandas 加速器模式現在與 NumPy 數組完全兼容。以前,對 pandas API 生成的 NumPy 數組運行 Python isinstance 檢查,在使用 cuDF pandas 時返回 False,在使用標準 pandas 時返回 True。由于這是一個常見的代碼設計模式,一些用戶工作流程需要變通方案才能順利運行。

    從 v24.10 開始,當加速器模式處于活動狀態且用戶嘗試將 DataFrame 或列轉換為數組時,cudf.pandas 現在可在功能上生成真正的 NumPy 數組 —— 消除了這個問題。例如:

    %load_ext cudf.pandas
    import pandas as pd
    import numpy as np
     
    arr = pd.Series([1, 2, 3]).values # now returns a true numpy array
    isinstance(arr, np.ndarray) # returns True

    此更改還使依賴 NumPy C API 的代碼能夠與 cuDF pandas 順暢協作。

    改進箭頭兼容性?

    cuDF 現在還支持一系列 PyArrow 版本。Arrow 兼容性一直是 cuDF 用戶的痛點。到目前為止,由于我們使用 Arrow C++ API 以及對二進制兼容性的要求,cuDF 的每個版本都與非常特定的 Arrow 版本相關聯。

    在此版本中,我們重寫了這些功能,僅使用 Arrow C 數據接口,這反過來又使我們完全停止使用 Arrow C++。通過這一更改,cuDF Python 現在可以支持自 PyArrow 4 以來的任何 PyArrow 版本。

    將 GPU 集成到基于 GitHub 的 CI 系統的指

    我們從社區了解到,找到一種簡單有效的方法將 GPU 整合到基于 GitHub 的 CI 系統中可能很有挑戰性。根據 scikit-learn 團隊 的經驗, RAPIDS 部署文檔 中添加了有效執行此操作的新指南。

    GitHub Actions 現已支持 托管的 GPU 運行程序 。這意味著 GitHub 上的任何項目都可以在其持續集成(CI)工作負載中利用 NVIDIA 的 GPU 進行測試。這使得項目更容易與 RAPIDS 庫集成,并在本地測試更改是否兼容,而無需在本地擁有 GPU 硬件。

    GPU 托管的運行者不包含在 GitHub Action 免費試用活動中。使用 GPU 的運行者 每分鐘的成本通常為幾美分 ,項目可以添加每月支出上限,以幫助控制成本。

    要設置 GPU 運行器,請導航至組織設置的“GitHub Actions”部分,并添加新的運行器。然后,選擇 NVIDIA 合作伙伴圖像,并將“Size”更改為由 GPU 提供支持的 VM,為您的運行器提供 GPU。

    creenshot showing the setup interface for creating a new GitHub Actions GPU runner. Fields include the runner's name, 'linux-nvidia-gpu,' with a 'Linux x64' platform selected. The image option displays 'Partner, NVIDIA GPU-Optimized Image for AI and HPC,' and size is set to 'GPU-powered' with specifications: '1 x NVIDIA T4 | 4-core | 16 GB VRAM | 176 GB SSD.' The 'Maximum concurrency' is configured to '50,' indicating the runner’s capability for concurrent tasks.
    圖 4、用于創建新 GitHub Actions GPU 運行器的設置界面。

    然后,您可以使用 runs-on 選項配置工作流,以使用新的 runners。

    name: GitHub Actions GPU Demo
    run-name: ${{ github.actor }} is testing out GPU GitHub Actions
    on: [push]
    jobs:
      gpu-workflow:
        runs-on: linux-nvidia-gpu
        steps:
          - name: Check GPU is available
            run: nvidia-smi

    有關設置 GitHub Actions GPU 驅動的工作流程的更多詳細信息,請參閱 RAPIDS 部署文檔 ,該文檔還包含有關何時運行 GPU CI 的最佳實踐,以便物盡其用。

    scikit-learn 項目最近在 GitHub Actions 上設置了 GPU 運行程序,使用標簽在選定的 PR 上手動觸發 GPU 工作流。查看 他們的博客文章 ,了解他們的經驗。

    RAPIDS 平臺更新?

    在 24.10 中,RAPIDS 軟件包接收了一些重要更新,可與其他科學計算軟件的更新版本一起使用。軟件包現在支持 Python 3.10-3.12 以及 NumPy 1.x 和 2.x。它們現在還支持 fmt 11 和 spdlog 1.14,這些庫的版本現已用于 conda-forge 的大部分版本。作為這些增強功能的一部分,此版本還取消了對 Python 3.9 或版本低于 2.19 的 NCCL 的支持。

    結束語?

    RAPIDS 24.10 版本進一步推進了我們的使命,即讓數據科學家和工程師更容易使用加速計算。我們迫不及待地想知道人們將如何使用這些新功能。

    如果您不熟悉 RAPIDS,請查看 這些資源 以開始使用。

    ?

    0

    標簽

    人人超碰97caoporen国产