惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
月光博客
月光博客
爱范儿
爱范儿
The Cloudflare Blog
Y
Y Combinator Blog
B
Blog RSS Feed
Stack Overflow Blog
Stack Overflow Blog
博客园 - 叶小钗
G
Google Developers Blog
J
Java Code Geeks
P
Proofpoint News Feed
美团技术团队
Engineering at Meta
Engineering at Meta
腾讯CDC
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
有赞技术团队
有赞技术团队
L
LangChain Blog
N
Netflix TechBlog - Medium
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 【当耐特】

StudyingLover's Blog

Diffusion Policy笔记 rwkv笔记 act笔记 nanovllm-block_manager opencode多智能体 nanobot-pre-train nanobot-rl nanobot-sft nanobot-checkpoint_manager nanobot-gpt nanobot-mid-train Vision Mamba (Vim)笔记 BPE演示 最后一遍学习Transformer YOLOv5 目标检测笔记 下载根服务器解析记录 Dynaseal A Backend-Controlled LLM API Key Distribution Scheme with Constrained Invocation Parameters 判断链表有环 王道25数据结构勘误 关于perplexity的open-sourcing-r1-1776 AI为什么不像人类一样进行多轮对话 新博客改造日记和功能测试 linuxqq只显示登陆背景图 数字设计和计算机体系结构(机械工业出版社)勘误(自制) Dynaseal:面向未来端侧llm agent的llm api key分发机制 A Definitive Guide to Markdown Style This post is using MDX, Where you can embed JSX and Astro components RT-Patch学习 pydantic实现的LLM ReAct fastapi 和 uvicorn 设置监听 ipv6
xgboost使用GPU最佳实践
About the Author StudyingLover · 2023-10-19 · via StudyingLover's Blog

xgboost使用GPU最佳实践

首先更新xgboost到2.0.0

pip install xgboost -U 

这里给出一个使用GPU的例子,使用的是nvidia显卡

import xgboost
import numpy as np
from scipy import stats

# 生成示例数据
np.random.seed(114514)
X = np.random.randn(100, 3)  # 生成100个样本,每个样本有3个特征
y = stats.bernoulli.rvs(0.5, size=100)  # 生成二分类标签,概率为0.5

# 设置参数
params = {
    "device": "cuda"
}

# 创建DMatrix对象
Xy = xgboost.DMatrix(X, y)

# 训练模型
model = xgboost.train(params, Xy)

# 测试模型
test_array = np.random.randn(1, 3)
dtest = xgboost.DMatrix(test_array)
pred = model.predict(dtest)
print(pred)