跳到内容

GPU 支持

Polars 为 Python 中的 Lazy API 提供了一个内存中的 GPU 加速执行引擎,它使用 NVIDIA GPU 上的 RAPIDS cuDF。此功能目前处于公开测试阶段,正在快速开发中,并且目前是单 GPU 实现。

如果您使用 GPU 功能标志安装 Polars,则可以通过运行 .collect(engine="gpu") 而不是 .collect() 来触发基于 GPU 的执行。

import polars as pl

df = pl.LazyFrame({"a": [1.242, 1.535]})

q = df.select(pl.col("a").round(1))

result = q.collect(engine="gpu")
print(result)
shape: (2, 1)
┌─────┐
│ a   │
│ --- │
│ f64 │
╞═════╡
│ 1.2 │
│ 1.5 │
└─────┘

GPU 支持指南中了解更多信息。