使用cuDF的GPU加速跨过滤
项目描述
cuxfilter
cuxfilter ( ku-cross-filter ) 是一个将网络可视化连接到GPU加速跨过滤的RAPIDS框架。受原始的javascript版本的启发,它通过cuDF,实现了交互式和超快的100百万+行表型数据集的多维过滤。
RAPIDS Viz
cuxfilter 是“RAPIDS viz”团队的核心项目之一。我们铭记着 @lmeyerov 的名言“一个滑动条胜过一千次查询”,希望通过更易于使用的Pythonic笔记本界面实现快速的数据分析。
由于网络上已经有很多出色的可视化库,我们的基本原则不是创建自己的viz库,而是通过更快的加速、更大的数据集和更好的开发体验来增强它们。 基本上,我们想要消除将多个图表连接到GPU后端的问题,让您能够更快地开始可视化数据。
顺便说一下,cuxfilter 最好用于交互式处理大型(1百万+)表型数据集。GPU很快,但访问这种加速需要一些架构开销,对于小数据集来说这是不值得的。
有关更详细的要求,请参阅以下内容。
cuxfilter 架构
当前版本的cuxfilter利用jupyter notebook和bokeh server来降低架构和安装复杂性。
开源项目
没有使用这些优秀的开源项目,cuxfilter是不可能实现的
原始的cuxfilter和Mortgage Viz Demo在哪里?
cuxfilter的原版(0.2)最著名的是为Mortgage Viz Demo提供后端支持,已经移至GTC-2018-mortgage-visualization分支
。由于其后端和javascript API非常复杂,我们决定更专注于这里简化的笔记本版本。
使用方法
示例1
import cuxfilter
#update data_dir if you have downloaded datasets elsewhere
DATA_DIR = './data'
from cuxfilter.sampledata import datasets_check
datasets_check('auto_accidents', base_dir=DATA_DIR)
cux_df = cuxfilter.DataFrame.from_arrow(DATA_DIR+'/auto_accidents.arrow')
cux_df.data['ST_CASE'] = cux_df.data['ST_CASE'].astype('float64')
label_map = {1: 'Sunday', 2: 'Monday', 3: 'Tuesday', 4: 'Wednesday', 5: 'Thursday', 6: 'Friday', 7: 'Saturday', 9: 'Unknown'}
cux_df.data['DAY_WEEK_STR'] = cux_df.data.DAY_WEEK.map(label_map)
gtc_demo_red_blue_palette = [ "#3182bd", "#6baed6", "#7b8ed8", "#e26798", "#ff0068" , "#323232" ]
#declare charts
chart1 = cuxfilter.charts.scatter(x='dropoff_x', y='dropoff_y', aggregate_col='DAY_WEEK', aggregate_fn='mean',
color_palette=gtc_demo_red_blue_palette, tile_provider='CartoLight', unselected_alpha=0.2,
pixel_shade_type='linear')
chart2 = cuxfilter.charts.multi_select('YEAR')
chart3 = cuxfilter.charts.bar('DAY_WEEK_STR')
chart4 = cuxfilter.charts.bar('MONTH')
#declare dashboard
d = cux_df.dashboard([chart1, chart3, chart4], sidebar=[chart2], layout=cuxfilter.layouts.feature_and_double_base, title='Auto Accident Dataset')
# run the dashboard as a webapp:
# Bokeh and Datashader based charts also have a `save` tool on the side toolbar, which can download and save the individual chart when interacting with the dashboard.
# d.show('jupyter-notebook/lab-url')
#run the dashboard within the notebook cell
d.app()
示例2
import cuxfilter
#update data_dir if you have downloaded datasets elsewhere
DATA_DIR = './data'
from cuxfilter.sampledata import datasets_check
datasets_check('mortgage', base_dir=DATA_DIR)
cux_df = cuxfilter.DataFrame.from_arrow(DATA_DIR + '/146M_predictions_v2.arrow')
geoJSONSource='https://raw.githubusercontent.com/rapidsai/cuxfilter/GTC-2018-mortgage-visualization/javascript/demos/GTC%20demo/src/data/zip3-ms-rhs-lessprops.json'
chart0 = cuxfilter.charts.choropleth( x='zip', color_column='delinquency_12_prediction', color_aggregate_fn='mean',
elevation_column='current_actual_upb', elevation_factor=0.00001, elevation_aggregate_fn='sum',
geoJSONSource=geoJSONSource
)
chart2 = cuxfilter.charts.bar('delinquency_12_prediction',data_points=50)
chart3 = cuxfilter.charts.range_slider('borrower_credit_score',data_points=50)
chart1 = cuxfilter.charts.drop_down('dti')
#declare dashboard
d = cux_df.dashboard([chart0, chart2],sidebar=[chart3, chart1], layout=cuxfilter.layouts.feature_and_double_base,theme = cuxfilter.themes.dark, title='Mortgage Dashboard')
# run the dashboard within the notebook cell
# Bokeh and Datashader based charts also have a `save` tool on the side toolbar, which can download and save the individual chart when interacting with the dashboard.
# d.app()
#run the dashboard as a webapp:
# if running on a port other than localhost:8888, run d.show(jupyter-notebook-lab-url:port)
d.show()
文档
完整的文档可以在RAPIDS文档页面找到。
故障排除帮助可以在我们的故障排除页面找到。
通用依赖
- python
- cudf
- datashader
- cupy
- panel
- bokeh
- pyproj
- geopandas
- pyppeteer
- jupyter-server-proxy
快速入门
请参阅Docker仓库示例,根据您运行的NVIDIA CUDA版本选择标签。这提供了一个带有示例笔记本和数据的可运行Docker容器,展示了如何利用cuxfilter、cuDF和其他RAPIDS库。
安装
CUDA/GPU要求
- CUDA 11.2+
- NVIDIA驱动程序 450.80.02+
- Pascal架构或更好(计算能力 >=6.0)
Conda
cuxfilter可以使用conda(miniconda或完整的Anaconda发行版)从rapidsai
频道安装
对于夜间版本cuxfilter版本 == 24.08
# for CUDA 12.0
conda install -c rapidsai-nightly -c conda-forge -c nvidia \
cuxfilter=24.08 python=3.11 cuda-version=12.0
# for CUDA 11.8
conda install -c rapidsai-nightly -c conda-forge -c nvidia \
cuxfilter=24.08 python=3.11 cuda-version=11.8
对于cuxfilter
的稳定版本
# for CUDA 12.0
conda install -c rapidsai -c conda-forge -c nvidia \
cuxfilter python=3.11 cuda-version=12.0
# for CUDA 11.8
conda install -c rapidsai -c conda-forge -c nvidia \
cuxfilter python=3.11 cuda-version=11.8
注意:cuxfilter仅在Linux上受支持,并且仅支持Python 3.8及以后的版本。
PyPI
使用pip从PyPI安装cuxfilter
# for CUDA 12.0
pip install cuxfilter-cu12 -extra-index-url=https://pypi.nvidia.com
# for CUDA 11.8
pip install cuxfilter-cu11 -extra-index-url=https://pypi.nvidia.com
有关更多操作系统和版本信息,请参阅RAPIDS版本选择器。
从源代码构建/安装
请参阅构建说明。
故障排除
jupyter lab中的bokeh服务器
要在jupyter lab中运行bokeh服务器,请安装jupyterlab依赖项
conda install -c conda-forge jupyterlab
jupyter labextension install @pyviz/jupyterlab_pyviz
jupyter labextension install jupyterlab_bokeh
下载数据集
- 自动下载数据集
python/notebooks
中的笔记本已经包含一个检查函数,该函数验证示例数据集是否已下载,如果没有则下载它。
- 手动下载
在您想要保存数据集的目录中执行以下操作
注意:自动事故数据集2012-2014年的坐标数据已损坏
#go the the environment where cuxfilter is installed. Skip if in a docker container
source activate test_env
#download and extract the datasets
curl https://s3.amazonaws.com/nyc-tlc/trip+data/yellow_tripdata_2015-01.csv --create-dirs -o ./nyc_taxi.csv
curl https://data.rapids.ai/viz-data/146M_predictions_v2.arrow.gz --create-dirs -o ./146M_predictions_v2.arrow.gz
curl https://data.rapids.ai/viz-data/auto_accidents.arrow.gz --create-dirs -o ./auto_accidents.arrow.gz
python -c "from cuxfilter.sampledata import datasets_check; datasets_check(base_dir='./')"
指南和布局模板
目前支持的布局模板和示例代码可以在布局页面找到。
目前支持的图表
库 | 图表类型 |
---|---|
bokeh | 柱状图 |
datashader | 散点图、散点地理图、折线图、堆叠折线图、热图、图表 |
面板小部件 | 范围滑块、日期范围滑块、浮点滑块、整数滑块、下拉菜单、多选、卡片、数字 |
自定义 | 查看数据框 |
deckgl | 等值线图(3D和2D) |
贡献者开发指南
cuxfilter像是一个连接库,很容易添加对新库的支持。在python/cuxfilter/charts/core
目录中,有所有核心图表类,可以继承并用于实现一些(可视化相关)函数,并在cuxfilter中直接支持仪表板。
您可以在bokeh和cudatashader目录中看到实现可视化库的示例。如果您想添加图表,请通过打开功能请求问题或提交PR来告诉我们。
有关更多详细信息,请参阅贡献指南。
未来工作
cuXfilter 的开发处于早期阶段,并且仍在进行中。查看我们接下来的计划,请访问 项目页面。
项目详情
cuxfilter_cu11-24.8.0.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | cbcd21459a02b29beecbb0ff2e46d2990f8f2646096b27cfec14d306d3627928 |
|
MD5 | ea963fb3e27bebca5f873f85322bde99 |
|
BLAKE2b-256 | 82f75ef866fdff98854f7b1352e89df880009433f14de6086022d57a2b432892 |