You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
File /usr/local/lib/python3.12/site-packages/cudf/core/indexed_frame.py:3572, in IndexedFrame._apply(self, func, kernel_class, *args, **kwargs)
3571 kr = kernel_class(self, func, args)
-> 3572 kernel, retty = kr.get_kernel()
3573 except Exception as e:
File /usr/local/lib/python3.12/site-packages/cudf/core/udf/udf_kernel_base.py:178, in ApplyKernelBase.get_kernel(self)
177defget_kernel(self):
--> 178 return self._compile_or_get_kernel()
File /usr/local/lib/python3.12/site-packages/cudf/core/udf/udf_kernel_base.py:195, in ApplyKernelBase._compile_or_get_kernel(self)
193return kernel, masked_or_scalar
--> 195 kernel, scalar_return_type = self.compile_kernel()
197 np_return_type = (
198 numpy_support.as_dtype(scalar_return_type)
199if scalar_return_type.is_internal
200else scalar_return_type.np_dtype
201 )
File /usr/local/lib/python3.12/site-packages/cudf/core/udf/udf_kernel_base.py:144, in ApplyKernelBase.compile_kernel(self)
143with capture_nrt_usage:
--> 144 return_type = self._get_udf_return_type()
146self.sig =self._construct_signature(return_type)
File /usr/local/lib/python3.12/site-packages/cudf/core/udf/udf_kernel_base.py:111, in ApplyKernelBase._get_udf_return_type(self)
110with _CUDFNumbaConfig():
--> 111 _, output_type = compile_udf(self.func, compile_sig)
112ifisinstance(output_type, MaskedType):
File /usr/local/lib/python3.12/site-packages/cudf/core/udf/utils.py:207, in compile_udf(udf, type_signature)
205# We haven't compiled a function like this before, so need to fall back to206# compilation with Numba
--> 207 ptx_code, return_type = cuda.compile_ptx_for_current_device(
208 udf, type_signature, device=True209 )
210ifnotisinstance(return_type, MaskedType):
File /usr/local/lib/python3.12/site-packages/numba/cuda/compiler.py:390, in compile_ptx_for_current_device(pyfunc, sig, debug, lineinfo, device, fastmath, opt, abi, abi_info)
388"""Compile a Python function to PTX for a given signature for the current389 device's compute capabilility. See :func:`compile_ptx`."""
--> 390 cc = get_current_device().compute_capability
391return compile_ptx(pyfunc, sig, debug=debug, lineinfo=lineinfo,
392 device=device, fastmath=fastmath, cc=cc, opt=opt,
393 abi=abi, abi_info=abi_info)
File /usr/local/lib/python3.12/site-packages/numba/cuda/api.py:443, in get_current_device()
442"Get current device associated with the current thread"
--> 443 return current_context().device
File /usr/local/lib/python3.12/site-packages/numba/cuda/cudadrv/devices.py:220, in get_context(devnum)
217"""Get the current device or use a device by device number, and218return the CUDA context.
219"""
--> 220 return _runtime.get_or_create_context(devnum)
File /usr/local/lib/python3.12/site-packages/numba/cuda/cudadrv/devices.py:138, in _Runtime.get_or_create_context(self, devnum)
137if attached_ctx isNone:
--> 138 return self._get_or_create_context_uncached(devnum)
139else:
File /usr/local/lib/python3.12/site-packages/numba/cuda/cudadrv/devices.py:158, in _Runtime._get_or_create_context_uncached(self, devnum)
156else:
157# Get primary context for the active device
--> 158 ctx = self.gpus[ac.devnum].get_primary_context()
159# Is active context the primary context?
File /usr/local/lib/python3.12/site-packages/numba/cuda/cudadrv/devices.py:40, in _DeviceList.__getitem__(self, devnum)
37'''38 Returns the context manager for device *devnum*.
39'''
---> 40 return self.lst[devnum]
IndexError: list index out of range
The above exception was the direct cause of the following exception:
ValueError Traceback (most recent call last)
Cell In[3], line 2
1 s = cudf.Series([1, 2, 3])
----> 2 s.apply(lambda x: x+1)
File /usr/local/lib/python3.12/site-packages/cudf/core/series.py:2692, in Series.apply(self, func, convert_dtype, args, by_row, **kwargs)
2689 elif by_row != "compat":
2690 raise NotImplementedError("by_row is currently not supported.")
-> 2692 result = self._apply(func, SeriesApplyKernel, *args, **kwargs)
2693 result.name = self.name
2694 return result
File /usr/local/lib/python3.12/contextlib.py:81, in ContextDecorator.__call__.<locals>.inner(*args, **kwds)
78@wraps(func)
79definner(*args, **kwds):
80withself._recreate_cm():
---> 81 return func(*args, **kwds)
File /usr/local/lib/python3.12/site-packages/cudf/core/indexed_frame.py:3574, in IndexedFrame._apply(self, func, kernel_class, *args, **kwargs)
3572 kernel, retty = kr.get_kernel()
3573 except Exception as e:
-> 3574 raise ValueError(
3575 "user defined function compilation failed."
3576 ) from e
3578 # Mask and data column preallocated
3579 ans_col = _return_arr_from_dtype(retty, len(self))
ValueError: user defined function compilation failed.
I'm able to install now, like %uv pip install "cudf-cu13==26.2.*" and after restarting the kernel I can run cudf code.
I'm having issues trying to run zero-code changes code. When I try to lead the %load_ext cudf.pandas the cell gets stuck in running, anthen I get a pop up with "Unexpected error" .
My guess is that Modal notebooks, don't work like regular notebooks when it comes to the % magic.
Activity
ncclementi commentedon Jan 16, 2026
I've been trying to get this to work, but I'm running into several issues.
The first approach I triad was to install
cudfviauvdirectly in the notebook as suggested in the docs.But when I try to use it and run some simple code, it fails, as it's not finding the GPUs, like it's not visible. Even though nvidia-smi shows the GPU
Steps to reproduce:
--------------------------------------------------------------------------- IndexError Traceback (most recent call last) File /usr/local/lib/python3.12/site-packages/cudf/core/indexed_frame.py:3572, in IndexedFrame._apply(self, func, kernel_class, *args, **kwargs) 3571 kr = kernel_class(self, func, args) -> 3572 kernel, retty = kr.get_kernel() 3573 except Exception as e: File /usr/local/lib/python3.12/site-packages/cudf/core/udf/udf_kernel_base.py:178, in ApplyKernelBase.get_kernel(self) 177 def get_kernel(self): --> 178 return self._compile_or_get_kernel() File /usr/local/lib/python3.12/site-packages/cudf/core/udf/udf_kernel_base.py:195, in ApplyKernelBase._compile_or_get_kernel(self) 193 return kernel, masked_or_scalar --> 195 kernel, scalar_return_type = self.compile_kernel() 197 np_return_type = ( 198 numpy_support.as_dtype(scalar_return_type) 199 if scalar_return_type.is_internal 200 else scalar_return_type.np_dtype 201 ) File /usr/local/lib/python3.12/site-packages/cudf/core/udf/udf_kernel_base.py:144, in ApplyKernelBase.compile_kernel(self) 143 with capture_nrt_usage: --> 144 return_type = self._get_udf_return_type() 146 self.sig = self._construct_signature(return_type) File /usr/local/lib/python3.12/site-packages/cudf/core/udf/udf_kernel_base.py:111, in ApplyKernelBase._get_udf_return_type(self) 110 with _CUDFNumbaConfig(): --> 111 _, output_type = compile_udf(self.func, compile_sig) 112 if isinstance(output_type, MaskedType): File /usr/local/lib/python3.12/site-packages/cudf/core/udf/utils.py:207, in compile_udf(udf, type_signature) 205 # We haven't compiled a function like this before, so need to fall back to 206 # compilation with Numba --> 207 ptx_code, return_type = cuda.compile_ptx_for_current_device( 208 udf, type_signature, device=True 209 ) 210 if not isinstance(return_type, MaskedType): File /usr/local/lib/python3.12/site-packages/numba/cuda/compiler.py:390, in compile_ptx_for_current_device(pyfunc, sig, debug, lineinfo, device, fastmath, opt, abi, abi_info) 388 """Compile a Python function to PTX for a given signature for the current 389 device's compute capabilility. See :func:`compile_ptx`.""" --> 390 cc = get_current_device().compute_capability 391 return compile_ptx(pyfunc, sig, debug=debug, lineinfo=lineinfo, 392 device=device, fastmath=fastmath, cc=cc, opt=opt, 393 abi=abi, abi_info=abi_info) File /usr/local/lib/python3.12/site-packages/numba/cuda/api.py:443, in get_current_device() 442 "Get current device associated with the current thread" --> 443 return current_context().device File /usr/local/lib/python3.12/site-packages/numba/cuda/cudadrv/devices.py:220, in get_context(devnum) 217 """Get the current device or use a device by device number, and 218 return the CUDA context. 219 """ --> 220 return _runtime.get_or_create_context(devnum) File /usr/local/lib/python3.12/site-packages/numba/cuda/cudadrv/devices.py:138, in _Runtime.get_or_create_context(self, devnum) 137 if attached_ctx is None: --> 138 return self._get_or_create_context_uncached(devnum) 139 else: File /usr/local/lib/python3.12/site-packages/numba/cuda/cudadrv/devices.py:158, in _Runtime._get_or_create_context_uncached(self, devnum) 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? File /usr/local/lib/python3.12/site-packages/numba/cuda/cudadrv/devices.py:40, in _DeviceList.__getitem__(self, devnum) 37 ''' 38 Returns the context manager for device *devnum*. 39 ''' ---> 40 return self.lst[devnum] IndexError: list index out of range The above exception was the direct cause of the following exception: ValueError Traceback (most recent call last) Cell In[3], line 2 1 s = cudf.Series([1, 2, 3]) ----> 2 s.apply(lambda x: x+1) File /usr/local/lib/python3.12/site-packages/cudf/core/series.py:2692, in Series.apply(self, func, convert_dtype, args, by_row, **kwargs) 2689 elif by_row != "compat": 2690 raise NotImplementedError("by_row is currently not supported.") -> 2692 result = self._apply(func, SeriesApplyKernel, *args, **kwargs) 2693 result.name = self.name 2694 return result File /usr/local/lib/python3.12/contextlib.py:81, in ContextDecorator.__call__.<locals>.inner(*args, **kwds) 78 @wraps(func) 79 def inner(*args, **kwds): 80 with self._recreate_cm(): ---> 81 return func(*args, **kwds) File /usr/local/lib/python3.12/site-packages/cudf/core/indexed_frame.py:3574, in IndexedFrame._apply(self, func, kernel_class, *args, **kwargs) 3572 kernel, retty = kr.get_kernel() 3573 except Exception as e: -> 3574 raise ValueError( 3575 "user defined function compilation failed." 3576 ) from e 3578 # Mask and data column preallocated 3579 ans_col = _return_arr_from_dtype(retty, len(self)) ValueError: user defined function compilation failed.cc: @charlesfrye
charlesfrye commentedon Feb 2, 2026
Hmm, I think you may need to restart the Notebook after installing libraries that touch the driver.
ncclementi commentedon Apr 6, 2026
I'm able to install now, like
%uv pip install "cudf-cu13==26.2.*"and after restarting the kernel I can run cudf code.I'm having issues trying to run zero-code changes code. When I try to lead the
%load_ext cudf.pandasthe cell gets stuck in running, anthen I get a pop up with "Unexpected error" .My guess is that Modal notebooks, don't work like regular notebooks when it comes to the
%magic.cc: @charlesfrye