holoviz / holoviews

With Holoviews, your data visualizes itself.
https://holoviews.org
BSD 3-Clause "New" or "Revised" License
2.67k stars 399 forks source link

Plotting using `cudf` fails #6090

Open jmakov opened 5 months ago

jmakov commented 5 months ago

ALL software version info

Python : 3.10.13 | packaged by conda-forge | (main, Dec 23 2023, 15:36:39) [GCC 12.3.0] Operating system : Linux-6.1.69-1-MANJARO-x86_64-with-glibc2.38 Panel comms : default

holoviews : 1.18.1

bokeh : 3.3.4 colorcet : 3.0.1 cudf : 23.12.01 dask : 2023.7.0 datashader : 0.16.0 geoviews : - hvplot : 0.9.2 ibis : - IPython : 8.20.0 jupyter_bokeh : 3.0.7 jupyterlab : 3.6.7 matplotlib : 3.6.0 networkx : 3.2.1 notebook : 6.5.6 numba : 0.58.0rc2 numpy : 1.24.4 pandas : 1.5.3 panel : 1.3.8 param : 2.0.2 PIL : 10.2.0 plotly : 5.18.0 pyarrow : 14.0.2 scipy : 1.10.1 skimage : - spatialpandas : - streamz : - xarray : 2024.1.1

cupy version: 13.0.0

Description of expected behavior and the observed behavior

Can't use cudf.

Complete, minimal, self-contained example code that reproduces the issue

import datashader as ds
import holoviews as hv
from holoviews.operation.datashader import datashade
import pandas as pd
hv.extension('bokeh')

df = pd.DataFrame(dict(
    x    = [0.0, 1.0, 0.0, 1.0, 0.0],
    y    = [0.0, 1.0, 1.0, 0.0, 0.5],
    cat  = ['a', 'b', 'a', 'b', 'a'],
))
df.cat = df.cat.astype("category")

# setting this to `True` throws an exception
if False:  
    import cudf
    df = cudf.DataFrame.from_pandas(df)

curve = hv.Curve(df)
datashade(curve, aggregator=ds.by("cat"))

Stack traceback and/or browser JavaScript console output

WARNING:param.dynamic_operation: Callable raised "RuntimeError('Runtime compilation failed')". Invoked as dynamic_operation(height=400, scale=1.0, width=400, x_range=None, y_range=None) --------------------------------------------------- --- JIT compile log for cupy_jitify_exercise --- --------------------------------------------------- cub/util_cpp_dialect.cuh(143): warning #161-D: unrecognized #pragma CUB_COMPILER_DEPRECATION_SOFT(C++14, C++11); ^ Remark: The warnings can be suppressed with "-diag-suppress " cooperative_groups/details/helpers.h(454): error: identifier "cudaCGGetIntrinsicHandle" is undefined return (cudaCGGetIntrinsicHandle(cudaCGScopeMultiGrid)); ^ cooperative_groups/details/helpers.h(459): error: identifier "cudaCGSynchronize" is undefined cudaError_t err = cudaCGSynchronize(handle, 0); ^ cooperative_groups/details/helpers.h(465): error: identifier "cudaCGGetSize" is undefined cudaCGGetSize(&numThreads, NULL, handle); ^ cooperative_groups/details/helpers.h(472): error: identifier "cudaCGGetRank" is undefined cudaCGGetRank(&threadRank, NULL, handle); ^ cooperative_groups/details/helpers.h(479): error: identifier "cudaCGGetRank" is undefined cudaCGGetRank(NULL, &gridRank, handle); ^ cooperative_groups/details/helpers.h(486): error: identifier "cudaCGGetSize" is undefined cudaCGGetSize(NULL, &numGrids, handle); ^ 6 errors detected in the compilation of "cupy_jitify_exercise". --------------------------------------------------- --------------------------------------------------------------------------- RuntimeError Traceback (most recent call last) File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/IPython/core/formatters.py:974, in MimeBundleFormatter.__call__(self, obj, include, exclude) 971 method = get_real_method(obj, self.print_method) 973 if method is not None: --> 974 return method(include=include, exclude=exclude) 975 return None 976 else: File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/holoviews/core/dimension.py:1286, in Dimensioned._repr_mimebundle_(self, include, exclude) 1279 def _repr_mimebundle_(self, include=None, exclude=None): 1280 """ 1281 Resolves the class hierarchy for the class rendering the 1282 object using any display hooks registered on Store.display 1283 hooks. The output of all registered display_hooks is then 1284 combined and returned. 1285 """ -> 1286 return Store.render(self) File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/holoviews/core/options.py:1428, in Store.render(cls, obj) 1426 data, metadata = {}, {} 1427 for hook in hooks: -> 1428 ret = hook(obj) 1429 if ret is None: 1430 continue File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/holoviews/ipython/display_hooks.py:287, in pprint_display(obj) 285 if not ip.display_formatter.formatters['text/plain'].pprint: 286 return None --> 287 return display(obj, raw_output=True) File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/holoviews/ipython/display_hooks.py:261, in display(obj, raw_output, **kwargs) 259 elif isinstance(obj, (HoloMap, DynamicMap)): 260 with option_state(obj): --> 261 output = map_display(obj) 262 elif isinstance(obj, Plot): 263 output = render(obj) File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/holoviews/ipython/display_hooks.py:149, in display_hook..wrapped(element) 147 try: 148 max_frames = OutputSettings.options['max_frames'] --> 149 mimebundle = fn(element, max_frames=max_frames) 150 if mimebundle is None: 151 return {}, {} File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/holoviews/ipython/display_hooks.py:209, in map_display(vmap, max_frames) 206 max_frame_warning(max_frames) 207 return None --> 209 return render(vmap) File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/holoviews/ipython/display_hooks.py:76, in render(obj, **kwargs) 73 if renderer.fig == 'pdf': 74 renderer = renderer.instance(fig='png') ---> 76 return renderer.components(obj, **kwargs) File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/holoviews/plotting/renderer.py:396, in Renderer.components(self, obj, fmt, comm, **kwargs) 393 embed = (not (dynamic or streams or self.widget_mode == 'live') or config.embed) 395 if embed or config.comms == 'default': --> 396 return self._render_panel(plot, embed, comm) 397 return self._render_ipywidget(plot) File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/holoviews/plotting/renderer.py:403, in Renderer._render_panel(self, plot, embed, comm) 401 doc = Document() 402 with config.set(embed=embed): --> 403 model = plot.layout._render_model(doc, comm) 404 if embed: 405 return render_model(model, comm) File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/panel/viewable.py:748, in Viewable._render_model(self, doc, comm) 746 if comm is None: 747 comm = state._comm_manager.get_server_comm() --> 748 model = self.get_root(doc, comm) 750 if self._design and self._design.theme.bokeh_theme: 751 doc.theme = self._design.theme.bokeh_theme File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/panel/layout/base.py:311, in Panel.get_root(self, doc, comm, preprocess) 307 def get_root( 308 self, doc: Optional[Document] = None, comm: Optional[Comm] = None, 309 preprocess: bool = True 310 ) -> Model: --> 311 root = super().get_root(doc, comm, preprocess) 312 # ALERT: Find a better way to handle this 313 if hasattr(root, 'styles') and 'overflow-x' in root.styles: File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/panel/viewable.py:666, in Renderable.get_root(self, doc, comm, preprocess) 664 wrapper = self._design._wrapper(self) 665 if wrapper is self: --> 666 root = self._get_model(doc, comm=comm) 667 if preprocess: 668 self._preprocess(root) File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/panel/layout/base.py:177, in Panel._get_model(self, doc, root, parent, comm) 175 root = root or model 176 self._models[root.ref['id']] = (model, parent) --> 177 objects, _ = self._get_objects(model, [], doc, root, comm) 178 props = self._get_properties(doc) 179 props[self._property_mapping['objects']] = objects File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/panel/layout/base.py:159, in Panel._get_objects(self, model, old_objects, doc, root, comm) 157 else: 158 try: --> 159 child = pane._get_model(doc, root, model, comm) 160 except RerenderError as e: 161 if e.layout is not None and e.layout is not self: File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/panel/pane/holoviews.py:423, in HoloViews._get_model(self, doc, root, parent, comm) 421 plot = self.object 422 else: --> 423 plot = self._render(doc, comm, root) 425 plot.pane = self 426 backend = plot.renderer.backend File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/panel/pane/holoviews.py:518, in HoloViews._render(self, doc, comm, root) 515 if comm: 516 kwargs['comm'] = comm --> 518 return renderer.get_plot(self.object, **kwargs) File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/holoviews/plotting/bokeh/renderer.py:68, in BokehRenderer.get_plot(self_or_cls, obj, doc, renderer, **kwargs) 61 @bothmethod 62 def get_plot(self_or_cls, obj, doc=None, renderer=None, **kwargs): 63 """ 64 Given a HoloViews Viewable return a corresponding plot instance. 65 Allows supplying a document attach the plot to, useful when 66 combining the bokeh model with another plot. 67 """ ---> 68 plot = super().get_plot(obj, doc, renderer, **kwargs) 69 if plot.document is None: 70 plot.document = Document() if self_or_cls.notebook_context else curdoc() File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/holoviews/plotting/renderer.py:217, in Renderer.get_plot(self_or_cls, obj, doc, renderer, comm, **kwargs) 214 raise SkipRendering(msg.format(dims=dims)) 216 # Initialize DynamicMaps with first data item --> 217 initialize_dynamic(obj) 219 if not renderer: 220 renderer = self_or_cls File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/holoviews/plotting/util.py:270, in initialize_dynamic(obj) 268 continue 269 if not len(dmap): --> 270 dmap[dmap._initial_key()] File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/holoviews/core/spaces.py:1216, in DynamicMap.__getitem__(self, key) 1214 # Not a cross product and nothing cached so compute element. 1215 if cache is not None: return cache -> 1216 val = self._execute_callback(*tuple_key) 1217 if data_slice: 1218 val = self._dataslice(val, data_slice) File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/holoviews/core/spaces.py:983, in DynamicMap._execute_callback(self, *args) 980 kwargs['_memoization_hash_'] = hash_items 982 with dynamicmap_memoization(self.callback, self.streams): --> 983 retval = self.callback(*args, **kwargs) 984 return self._style(retval) File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/holoviews/core/spaces.py:581, in Callable.__call__(self, *args, **kwargs) 578 args, kwargs = (), dict(pos_kwargs, **kwargs) 580 try: --> 581 ret = self.callable(*args, **kwargs) 582 except KeyError: 583 # KeyError is caught separately because it is used to signal 584 # invalid keys on DynamicMap and should not warn 585 raise File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/holoviews/util/__init__.py:1034, in Dynamic._dynamic_operation..dynamic_operation(*key, **kwargs) 1032 def dynamic_operation(*key, **kwargs): 1033 key, obj = resolve(key, kwargs) -> 1034 return apply(obj, *key, **kwargs) File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/holoviews/util/__init__.py:1026, in Dynamic._dynamic_operation..apply(element, *key, **kwargs) 1024 def apply(element, *key, **kwargs): 1025 kwargs = dict(util.resolve_dependent_kwargs(self.p.kwargs), **kwargs) -> 1026 processed = self._process(element, key, kwargs) 1027 if (self.p.link_dataset and isinstance(element, Dataset) and 1028 isinstance(processed, Dataset) and processed._dataset is None): 1029 processed._dataset = element.dataset File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/holoviews/util/__init__.py:1008, in Dynamic._process(self, element, key, kwargs) 1006 elif isinstance(self.p.operation, Operation): 1007 kwargs = {k: v for k, v in kwargs.items() if k in self.p.operation.param} -> 1008 return self.p.operation.process_element(element, key, **kwargs) 1009 else: 1010 return self.p.operation(element, **kwargs) File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/holoviews/core/operation.py:194, in Operation.process_element(self, element, key, **params) 191 else: 192 self.p = param.ParamOverrides(self, params, 193 allow_extra_keywords=self._allow_extra_keywords) --> 194 return self._apply(element, key) File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/holoviews/core/operation.py:141, in Operation._apply(self, element, key) 139 if not in_method: 140 element._in_method = True --> 141 ret = self._process(element, key) 142 if hasattr(element, '_in_method') and not in_method: 143 element._in_method = in_method File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/holoviews/operation/datashader.py:1526, in datashade._process(self, element, key) 1524 def _process(self, element, key=None): 1525 agg = rasterize._process(self, element, key) -> 1526 shaded = shade._process(self, agg, key) 1527 return shaded File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/holoviews/operation/datashader.py:1328, in shade._process(self, element, key) 1326 with warnings.catch_warnings(): 1327 warnings.filterwarnings('ignore', r'invalid value encountered in true_divide') -> 1328 if np.isnan(array.data).all(): 1329 xd, yd = kdims[:2] 1330 arr = np.zeros(array.data.shape[:2]+(4,), dtype=np.uint8) File cupy/_core/core.pyx:1169, in cupy._core.core._ndarray_base.all() File cupy/_core/core.pyx:1171, in cupy._core.core._ndarray_base.all() File cupy/_core/_routines_logic.pyx:8, in cupy._core._routines_logic._ndarray_all() File cupy/_core/_reduction.pyx:618, in cupy._core._reduction._SimpleReductionKernel.__call__() File cupy/_core/_reduction.pyx:370, in cupy._core._reduction._AbstractReductionKernel._call() File cupy/_core/_cub_reduction.pyx:689, in cupy._core._cub_reduction._try_to_call_cub_reduction() File cupy/_core/_cub_reduction.pyx:526, in cupy._core._cub_reduction._launch_cub() File cupy/_core/_cub_reduction.pyx:461, in cupy._core._cub_reduction._cub_two_pass_launch() File cupy/_util.pyx:64, in cupy._util.memoize.decorator.ret() File cupy/_core/_cub_reduction.pyx:240, in cupy._core._cub_reduction._SimpleCubReductionKernel_get_cached_function() File cupy/_core/_cub_reduction.pyx:223, in cupy._core._cub_reduction._create_cub_reduction_function() File cupy/_core/core.pyx:2254, in cupy._core.core.compile_with_cache() File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/cupy/cuda/compiler.py:484, in _compile_module_with_cache(source, options, arch, cache_dir, extra_source, backend, enable_cooperative_groups, name_expressions, log_stream, jitify) 480 return _compile_with_cache_hip( 481 source, options, arch, cache_dir, extra_source, backend, 482 name_expressions, log_stream, cache_in_memory) 483 else: --> 484 return _compile_with_cache_cuda( 485 source, options, arch, cache_dir, extra_source, backend, 486 enable_cooperative_groups, name_expressions, log_stream, 487 cache_in_memory, jitify) File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/cupy/cuda/compiler.py:562, in _compile_with_cache_cuda(source, options, arch, cache_dir, extra_source, backend, enable_cooperative_groups, name_expressions, log_stream, cache_in_memory, jitify) 560 if backend == 'nvrtc': 561 cu_name = '' if cache_in_memory else name + '.cu' --> 562 ptx, mapping = compile_using_nvrtc( 563 source, options, arch, cu_name, name_expressions, 564 log_stream, cache_in_memory, jitify) 565 if _is_cudadevrt_needed(options): 566 # for separate compilation 567 ls = function.LinkState() File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/cupy/cuda/compiler.py:319, in compile_using_nvrtc(source, options, arch, filename, name_expressions, log_stream, cache_in_memory, jitify) 316 with open(cu_path, 'w') as cu_file: 317 cu_file.write(source) --> 319 return _compile(source, options, cu_path, 320 name_expressions, log_stream, jitify) 321 else: 322 cu_path = '' if not jitify else filename File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/cupy/cuda/compiler.py:284, in compile_using_nvrtc.._compile(source, options, cu_path, name_expressions, log_stream, jitify) 280 def _compile( 281 source, options, cu_path, name_expressions, log_stream, jitify): 283 if jitify: --> 284 options, headers, include_names = _jitify_prep( 285 source, options, cu_path) 286 else: 287 headers = include_names = () File ~/mambaforge-pypy3/envs/venv/lib/python3.10/site-packages/cupy/cuda/compiler.py:233, in _jitify_prep(source, options, cu_path) 231 if not _jitify_header_source_map_populated: 232 from cupy._core import core --> 233 jitify._init_module() 234 jitify._add_sources(core._get_header_source_map()) 235 _jitify_header_source_map_populated = True File cupy/cuda/jitify.pyx:212, in cupy.cuda.jitify._init_module() File cupy/cuda/jitify.pyx:233, in cupy.cuda.jitify._init_module() File cupy/cuda/jitify.pyx:209, in cupy.cuda.jitify._init_cupy_headers() File cupy/cuda/jitify.pyx:192, in cupy.cuda.jitify._init_cupy_headers_from_scratch() File cupy/cuda/jitify.pyx:264, in cupy.cuda.jitify.jitify() RuntimeError: Runtime compilation failed :DynamicMap []

Screenshots or screencasts of the bug in action

hoxbro commented 5 months ago

I'm seeing the warnings you are seeing, but my plot shows up in the end:

image

Output of hv.show_versions:

Python              :  3.10.13 | packaged by conda-forge | (main, Dec 23 2023, 15:36:39) [GCC 12.3.0]
Operating system    :  Linux-6.6.10-76060610-generic-x86_64-with-glibc2.35
Panel comms         :  default

holoviews           :  1.18.2a2.post38+g0297598c9

bokeh               :  3.3.4
colorcet            :  3.0.1.post15+g34b3992
cudf                :  23.8.0
dask                :  2023.7.1
datashader          :  0.16.1a1.post1+g90ad4cb
geoviews            :  1.11.1a1.post2+gab02bcb
hvplot              :  0.9.2.post3+g95e39e7
ibis-framework      :  7.2.0
IPython             :  8.20.0
jupyter_bokeh       :  3.0.7
jupyterlab          :  3.6.7
matplotlib          :  3.8.2
networkx            :  3.2.1
notebook            :  6.5.6
numba               :  0.58.1
numpy               :  1.26.3
pandas              :  1.5.3
panel               :  1.4.0a1.post32+ga18106b5.dirty
param               :  2.0.3.dev1+g615dbe8.d20240131
pillow              :  10.2.0
plotly              :  5.18.0
pyarrow             :  11.0.0
pyviz_comms         :  2.3.2
scikit-image        :  0.22.0
scipy               :  1.12.0
spatialpandas       :  0.4.10
streamz             :  0.6.4
tsdownsample        :  0.1.2
xarray              :  2024.1.1

And cupy version is 13.

jmakov commented 5 months ago

@Hoxbro thanks a lot for the quick feedback. OK, so it is doable :) . I've added the output of .show_versions to the original post. From a quick look, doesn't seem to be any very old lib version. Perhaps sth connected with CUDA - I'm installing it via conda? From the traceback it looks like cupy.cuda.jitify.jitify() failed.

hoxbro commented 5 months ago

Maybe try to downgrade to a numba non-rc version.

jmakov commented 5 months ago

Tried numba 0.58.1, same exception