Skip to content

GPU 支持

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

如果您使用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支持指南