-
Notifications
You must be signed in to change notification settings - Fork 335
Description
Version
25.04
Which installation method(s) does this occur on?
Conda
Describe the bug.
I was trying to run leiden/louvain algorithm with cugraph. When printing results, there appears an indexerror.
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
import cudf
import cugraph
import numpy as np
import cupy as cp
print("avaliable GPU:", cp.cuda.runtime.getDeviceCount())
# test
n_vertices = 1000
n_edges = 5000
src = np.random.randint(0, n_vertices, size=n_edges, dtype=np.int32)
dst = np.random.randint(0, n_vertices, size=n_edges, dtype=np.int32)
gdf = cudf.DataFrame({'src': src, 'dst': dst})
G = cugraph.Graph()
G.from_cudf_edgelist(gdf, source='src', destination='dst', renumber=False)
print("vertices:", G.number_of_vertices(), "edges:", G.number_of_edges())
parts, mod = cugraph.leiden(G)
IndexError Traceback (most recent call last)
File ~/anaconda3/envs/rapids-25.04/lib/python3.12/site-packages/IPython/core/formatters.py:770, in PlainTextFormatter.call(self, obj)
763 stream = StringIO()
764 printer = pretty.RepresentationPrinter(stream, self.verbose,
765 self.max_width, self.newline,
766 max_seq_length=self.max_seq_length,
767 singleton_pprinters=self.singleton_printers,
768 type_pprinters=self.type_printers,
769 deferred_pprinters=self.deferred_printers)
--> 770 printer.pretty(obj)
771 printer.flush()
772 return stream.getvalue()
File ~/anaconda3/envs/rapids-25.04/lib/python3.12/site-packages/IPython/lib/pretty.py:411, in RepresentationPrinter.pretty(self, obj)
400 return meth(obj, self, cycle)
401 if (
402 cls is not object
403 # check if cls defines repr
(...) 409 and callable(_safe_getattr(cls, "repr", None))
410 ):
--> 411 return _repr_pprint(obj, self, cycle)
413 return _default_pprint(obj, self, cycle)
414 finally:
File ~/anaconda3/envs/rapids-25.04/lib/python3.12/site-packages/IPython/lib/pretty.py:786, in repr_pprint(obj, p, cycle)
784 """A pprint that just redirects to the normal repr function."""
785 # Find newlines and replace them with p.break()
--> 786 output = repr(obj)
787 lines = output.splitlines()
788 with p.group():
File ~/anaconda3/envs/rapids-25.04/lib/python3.12/site-packages/cudf/utils/performance_tracking.py:51, in _performance_tracking..wrapper(*args, **kwargs)
43 if nvtx.enabled():
44 stack.enter_context(
45 nvtx.annotate(
46 message=func.qualname,
(...) 49 )
50 )
---> 51 return func(*args, **kwargs)
File ~/anaconda3/envs/rapids-25.04/lib/python3.12/site-packages/cudf/core/dataframe.py:2028, in DataFrame.repr(self)
2025 @_performance_tracking
2026 def repr(self):
2027 output = self._get_renderable_dataframe()
-> 2028 return self._clean_renderable_dataframe(output)
File ~/anaconda3/envs/rapids-25.04/lib/python3.12/site-packages/cudf/core/dataframe.py:1927, in DataFrame._clean_renderable_dataframe(self, output)
1924 else:
1925 width = None
-> 1927 output = output.to_pandas().to_string(
1928 max_rows=max_rows,
1929 min_rows=min_rows,
1930 max_cols=max_cols,
1931 line_width=width,
1932 max_colwidth=max_colwidth,
1933 show_dimensions=show_dimensions,
1934 )
1936 lines = output.split("\n")
1938 if lines[-1].startswith("["):
File ~/anaconda3/envs/rapids-25.04/lib/python3.12/site-packages/cudf/utils/performance_tracking.py:51, in _performance_tracking..wrapper(*args, **kwargs)
43 if nvtx.enabled():
44 stack.enter_context(
45 nvtx.annotate(
46 message=func.qualname,
(...) 49 )
50 )
---> 51 return func(*args, **kwargs)
File ~/anaconda3/envs/rapids-25.04/lib/python3.12/site-packages/cudf/core/dataframe.py:5517, in DataFrame.to_pandas(self, nullable, arrow_type)
5439 @_performance_tracking
5440 def to_pandas(
5441 self, *, nullable: bool = False, arrow_type: bool = False
5442 ) -> pd.DataFrame:
5443 """
5444 Convert to a Pandas DataFrame.
5445
(...) 5515 dtype: object
5516 """
-> 5517 out_index = self.index.to_pandas()
5518 out_data = {
5519 i: col.to_pandas(nullable=nullable, arrow_type=arrow_type)
5520 for i, col in enumerate(self._columns)
5521 }
5523 out_df = pd.DataFrame(out_data, index=out_index)
File ~/anaconda3/envs/rapids-25.04/lib/python3.12/site-packages/cudf/core/index.py:1659, in Index.to_pandas(self, nullable, arrow_type)
1656 def to_pandas(
1657 self, *, nullable: bool = False, arrow_type: bool = False
1658 ) -> pd.Index:
-> 1659 result = self._column.to_pandas(
1660 nullable=nullable, arrow_type=arrow_type
1661 )
1662 result.name = self.name
1663 return result
File ~/anaconda3/envs/rapids-25.04/lib/python3.12/site-packages/cudf/core/column/numerical.py:709, in NumericalColumn.to_pandas(self, nullable, arrow_type)
707 return pd.Index(pandas_array, copy=False)
708 elif self.dtype.kind in set("iuf") and not self.has_nulls():
--> 709 return pd.Index(self.values_host, copy=False)
710 else:
711 return super().to_pandas(nullable=nullable, arrow_type=arrow_type)
File ~/anaconda3/envs/rapids-25.04/lib/python3.12/site-packages/cudf/core/column/column.py:664, in ColumnBase.values_host(self)
661 raise ValueError("Column must have no nulls.")
663 with acquire_spill_lock():
--> 664 return self.data_array_view(mode="read").copy_to_host()
File ~/anaconda3/envs/rapids-25.04/lib/python3.12/site-packages/cudf/core/column/column.py:568, in ColumnBase.data_array_view(self, mode)
566 else:
567 obj = None
--> 568 return cuda.as_cuda_array(obj).view(self.dtype)
File ~/anaconda3/envs/rapids-25.04/lib/python3.12/site-packages/numba_cuda/numba/cuda/api.py:76, in as_cuda_array(obj, sync)
74 raise TypeError("obj doesn't implement the cuda array interface.")
75 else:
---> 76 return from_cuda_array_interface(obj.cuda_array_interface,
77 owner=obj, sync=sync)
File ~/anaconda3/envs/rapids-25.04/lib/python3.12/site-packages/numba_cuda/numba/cuda/cudadrv/devices.py:231, in require_context.._require_cuda_context(*args, **kws)
229 @functools.wraps(fn)
230 def _require_cuda_context(*args, **kws):
--> 231 with _runtime.ensure_context():
232 return fn(*args, **kws)
File ~/anaconda3/envs/rapids-25.04/lib/python3.12/contextlib.py:137, in _GeneratorContextManager.enter(self)
135 del self.args, self.kwds, self.func
136 try:
--> 137 return next(self.gen)
138 except StopIteration:
139 raise RuntimeError("generator didn't yield") from None
File ~/anaconda3/envs/rapids-25.04/lib/python3.12/site-packages/numba_cuda/numba/cuda/cudadrv/devices.py:123, in _Runtime.ensure_context(self)
121 with driver.get_active_context():
122 oldctx = self._get_attached_context()
--> 123 newctx = self.get_or_create_context(None)
124 self._set_attached_context(newctx)
125 try:
File ~/anaconda3/envs/rapids-25.04/lib/python3.12/site-packages/numba_cuda/numba/cuda/cudadrv/devices.py:138, in _Runtime.get_or_create_context(self, devnum)
136 attached_ctx = self._get_attached_context()
137 if attached_ctx is None:
--> 138 return self._get_or_create_context_uncached(devnum)
139 else:
140 return attached_ctx
File ~/anaconda3/envs/rapids-25.04/lib/python3.12/site-packages/numba_cuda/numba/cuda/cudadrv/devices.py:158, in _Runtime._get_or_create_context_uncached(self, devnum)
155 return self._activate_context_for(0)
156 else:
157 # Get primary context for the active device
--> 158 ctx = self.gpus[ac.devnum].get_primary_context()
159 # Is active context the primary context?
160 if USE_NV_BINDING:
File ~/anaconda3/envs/rapids-25.04/lib/python3.12/site-packages/numba_cuda/numba/cuda/cudadrv/devices.py:40, in _DeviceList.getitem(self, devnum)
36 def getitem(self, devnum):
37 '''
38 Returns the context manager for device devnum.
39 '''
---> 40 return self.lst[devnum]
IndexError: list index out of range
Minimum reproducible example
Relevant log output
Environment details
Other/Misc.
No response
Code of Conduct
- I agree to follow cuGraph's Code of Conduct
- I have searched the open bugs and have found no duplicates for this bug report