I’m trying to build an example using cugraph::sssp and though I’m linking in the right libraries, I am getting this error:
undefined reference to 'void cugraph::sssp<int, int, float, false>(raft::handle_t const&,
cugraph::graph_view_t<int, int, false, false, void> const&, cugraph::edge_property_view_t<int, float const*,
thrust::THRUST_200302_700_NS::iterator_traits<float const*>::value_type>, float*, int*, int, float, bool)'
Here’s my code:
#include <cugraph/graph.hpp>
#include <cugraph/algorithms.hpp>
#include <cugraph/graph_functions.hpp>
#include <rmm/device_uvector.hpp>
#include <rmm/device_buffer.hpp>
#include <raft/core/handle.hpp>
#include <iostream>
int main()
{
// Initialize RAFT handle
raft::handle_t handle;
// Define the graph edges (source, destination, weight)
std::vector<int> h_vtx = {0, 1, 2, 3, 4};
std::vector<int> h_src = {0, 0, 1, 2, 2, 3};
std::vector<int> h_dst = {1, 2, 3, 3, 4, 4};
std::vector<float> h_wgt = {1.0, 2.0, 1.0, 1.0, 3.0, 1.0};
// Number of vertices
int num_vertices = 5;
// Transfer data to device
rmm::device_uvector<int> d_vtx(h_vtx.size(), handle.get_stream());
rmm::device_uvector<int> d_src(h_src.size(), handle.get_stream());
rmm::device_uvector<int> d_dst(h_dst.size(), handle.get_stream());
rmm::device_uvector<float> d_wgt(h_wgt.size(), handle.get_stream());
raft::update_device(d_wgt.data(), h_wgt.data(), h_wgt.size(), handle.get_stream());
raft::update_device(d_src.data(), h_src.data(), h_src.size(), handle.get_stream());
raft::update_device(d_dst.data(), h_dst.data(), h_dst.size(), handle.get_stream());
raft::update_device(d_wgt.data(), h_wgt.data(), h_wgt.size(), handle.get_stream());
// Create graph
auto [graph, edge_weights, a, b, c] = cugraph::create_graph_from_edgelist<int,
int,
float, int,
false, false>(
handle,
std::move(d_vtx),
std::move(d_src),
std::move(d_dst),
std::move(d_wgt),
std::nullopt,
std::nullopt,
// std::nullopt,
cugraph::graph_properties_t{false, false},
false, false);
// Allocate memory for distances
rmm::device_uvector<float> distances(num_vertices, handle.get_stream());
rmm::device_uvector<int> d_predecessors(num_vertices, handle.get_stream());
auto edge_weight_view = std::make_optional((*edge_weights).view());
// Run SSSP
int source_vertex = 0;
cugraph::sssp(handle,
graph.view(),
*edge_weight_view,
distances.data(),
d_predecessors.data(),
source_vertex);
// Transfer results back to host
std::vector<float> h_distances(num_vertices);
raft::update_host(h_distances.data(), distances.data(), num_vertices, handle.get_stream());
handle.sync_stream();
// Print distances
std::cout << "Distances from source vertex " << source_vertex << ":\n";
for (int i = 0; i < num_vertices; ++i)
{
std::cout << "Vertex " << i << ": " << h_distances[i] << "\n";
}
return 0;
}
And here’s my cmdline to compile it:
nvcc -arch=sm_70 -DLIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE -o test ./main.cu -lcugraph -lraft
Since sssp is a template function, how could it have an undefined reference? Thanks for your help!