cuGraph graph_view_t 构造函数错误:“offsets.size() 返回无效值”

问题描述 投票:0回答:1

我在尝试使用 CUDA 中的 cuGraph 库创建图形视图时遇到问题。具体来说,我使用

graph_view_t
构造函数从表示图形偏移和索引的设备跨度创建图形视图。但是,我始终收到错误消息:“cuGraph 在 file=/root/cugraph/cpp/src/struct/graph_view_impl.cuh line=533 处失败:内部错误:offsets.size() 返回无效值。”

   raft::handle_t handle;
   

    rmm::device_uvector<long> d_source_offsets(source_offsets->size(), stream);
    rmm::device_uvector<long> d_destination_indices(destination_indices->size(), stream);

    CUDA_CHECK(cudaMemcpyAsync(
        d_source_offsets.data(),
        source_offsets->data(),
        source_offsets->size() * sizeof(long),
        cudaMemcpyHostToDevice,
        stream.value()));

    CUDA_CHECK(cudaMemcpyAsync(
        d_destination_indices.data(),
        destination_indices->data(),
        destination_indices->size() * sizeof(long),
        cudaMemcpyHostToDevice,
        stream.value()));


    stream.synchronize();


    raft::device_span<long> offsets_span(d_source_offsets.data(), d_source_offsets.size());
    raft::device_span<long> indices_span(d_destination_indices.data(), d_destination_indices.size());

   
    cugraph::graph_view_t<long, long, false, false> graph_view(offsets_span, indices_span, {});

任何关于为什么会发生此错误以及如何解决它的见解将不胜感激。谢谢!

c++ parallel-processing cuda gpu nvidia
1个回答
1
投票

我们的典型用例是用户使用函数

graph_t
创建
create_graph_from_edgelist
,然后从中创建
graph_view_t
。如果顶点按度数排序(最大的在前),我们可以在图形算法的 CUDA 内核中进行一些优化,并且有一些额外的数据结构可以帮助我们识别和促进这一点。当然,
create_graph_from_edgelist
需要COO输入,因此如果您有CSR输入并且不想转换,您当然可以根据您的数据结构自己创建
graph_view_t
。当您使用
graph_view_t
时,您可能会错过一些优化机会。

graph_view_t
的构造函数需要正确填充第三个参数。您看到的失败来自对输入参数的检查。

https://github.com/rapidsai/cugraph/blob/7904ff07d4a9a9b567193e46f9a6ed50ab6649f2/cpp/include/cugraph/graph_view.hpp#L348标识了

graph_view_meta_t
的单GPU变体的结构。您需要为 3 个非可选字段提供值。

这是我们构建单 GPU 的示例

graph_view_t
https://github.com/rapidsai/cugraph/blob/7904ff07d4a9a9b567193e46f9a6ed50ab6649f2/cpp/include/cugraph/graph.hpp#L289.

按如下方式扩展您的代码应该足够了:

cugraph::graph_view_t<long, long, false, false> graph_view(offsets_span, indices_span, cugraph::graph_view_meta_t<long, long, false, false>{
    static_cast<long>(offsets_span.size() - 1), static_cast<long>(indices_span.size()), cugraph::graph_properties_t{false, true}});

您可以根据自己的情况设置图形属性,第一个元素是图形是否对称,第二个元素是图形是否是多重图。

© www.soinside.com 2019 - 2024. All rights reserved.