Skip to content

Latest commit

 

History

History
50 lines (36 loc) · 1.13 KB

File metadata and controls

50 lines (36 loc) · 1.13 KB

快速上手

语言: 中文
最后更新: 2026-04-11
页面定位: 快速开始
切换: English

语言切换:English

安装

cd statgpu
pip install -e .

最小示例

import numpy as np
from statgpu.linear_model import LinearRegression

X = np.random.randn(1000, 20)
y = X @ np.random.randn(20) + 0.1 * np.random.randn(1000)

model = LinearRegression(device="cuda")
model.fit(X, y)
print(model.score(X, y))

常用设备控制

import statgpu as sg

sg.set_device("auto")   # 默认: 有 CUDA 就用 GPU
sg.set_device("cuda")   # 强制 GPU
sg.set_device("cpu")    # 强制 CPU
print(sg.get_device().value)   # 当前解析后的设备(如 cuda / cpu)

更多内容见:

推荐下一步