Skip to content

[BUG]Leiden #604

@shanggutianzhen

Description

@shanggutianzhen

Describe the bug
Hello, I encountered this problem when performing the Leiden clustering.

Steps/Code to reproduce bug

IndexError Traceback (most recent call last)
Cell In[11], line 1
----> 1 rsc.tl.leiden(adata, resolution=0.8)
229 @functools.wraps(fn)
File ~/miniconda3/envs/RSC/lib/python3.12/site-packages/rapids_singlecell/tools/_clustering.py:137, in leiden(adata, resolution, random_state, restrict_to, key_added, adjacency, n_iterations, use_weights, neighbors_key, obsp, copy)
128 leiden_parts, _ = culeiden(
129 g,
130 resolution=resolution,
131 random_state=random_state,
132 max_iter=n_iterations,
133 )
135 # Format output
136 groups = (
--> 137 leiden_parts.to_pandas().sort_values("vertex")[["partition"]].to_numpy().ravel()
138 )
139 if restrict_to is not None:
140 if key_added == "leiden":

File ~/miniconda3/envs/RSC/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 ~/miniconda3/envs/RSC/lib/python3.12/site-packages/cudf/core/dataframe.py:5482, in DataFrame.to_pandas(self, nullable, arrow_type)
5406 """
5407 Convert to a Pandas DataFrame.
5408
(...)
5478 dtype: object
5479 """
5480 out_index = self.index.to_pandas()
5481 out_data = {
-> 5482 i: col.to_pandas(nullable=nullable, arrow_type=arrow_type)
5483 for i, col in enumerate(self._columns)
5484 }
5486 out_df = pd.DataFrame(out_data, index=out_index)
5487 out_df.columns = self._data.to_pandas_index()

File ~/miniconda3/envs/RSC/lib/python3.12/site-packages/cudf/core/column/numerical.py:711, in NumericalColumn.to_pandas(self, nullable, arrow_type)
709 return pd.Index(pandas_array, copy=False)
710 elif self.dtype.kind in set("iuf") and not self.has_nulls():
--> 711 return pd.Index(self.values_host, copy=False)
712 else:
713 return super().to_pandas(nullable=nullable, arrow_type=arrow_type)

File ~/miniconda3/envs/RSC/lib/python3.12/site-packages/cudf/core/column/column.py:220, in ColumnBase.values_host(self)
217 raise ValueError("Column must have no nulls.")
219 with acquire_spill_lock():
--> 220 return self.data_array_view(mode="read").copy_to_host()

File ~/miniconda3/envs/RSC/lib/python3.12/site-packages/cudf/core/column/column.py:135, in ColumnBase.data_array_view(self, mode)
133 else:
134 obj = None
--> 135 return cuda.as_cuda_array(obj).view(self.dtype)

File ~/miniconda3/envs/RSC/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 ~/miniconda3/envs/RSC/lib/python3.12/site-packages/numba_cuda/numba/cuda/cudadrv/devices.py:231, in require_context.._require_cuda_co@Fast ntext(*args, **kws)
230 def _require_cuda_context(*args, **kws):
--> 231 with _runtime.ensure_context():
232 return fn(*args, **kws)

File ~/miniconda3/envs/RSC/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 ~/miniconda3/envs/RSC/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 ~/miniconda3/envs/RSC/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 ~/miniconda3/envs/RSC/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 ~/miniconda3/envs/RSC/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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions