前言
参加了Datawhale的AI夏令营第二期的机器学习赛道~,没错这次还是机器学习
baseline:https://aistudio.baidu.com/aistudio/projectdetail/6598302?sUid=2554132&shared=1&ts=1690895519028
问题
由于在使用cpu训练时很慢,且飞浆又为我们免费提供了GPU算力,就像尝试如何使用GPU训练进行加速
解决
catboost官方文档: https://catboost.ai/docs/
在文档中不难找到调用GPU的方式: https://catboost.ai/docs/features/training-on-gpu
# For example, use the following code to train a classification model on GPU:
from catboost import CatBoostClassifier
train_data = [[0, 3],
[4, 1],
[8, 1],
[9, 1]]
train_labels = [0, 0, 1, 1]
model = CatBoostClassifier(iterations=1000,
task_type="GPU",
devices='0:1')
model.fit(train_data,
train_labels,
verbose=False)
catboost相比于第一期的baseline所使用的LightGBM,无需再使用root环境安装额外的gpu环境即可调用gpu
在本次的baseline中,只需在cv_model
函数中的line15
中的params: dict
中添加一个键即可:'task_type' : 'GPU'
芜湖~速度起飞~~~
评论 (0)