【发布时间】:2019-01-11 13:30:10
【问题描述】:
我正在尝试在 Google Colaboratory 上将 XGBoost 与 GPU 结合使用。这是我的笔记本:
import numpy as np
import os
import xgboost as xgb
train_X = np.random.rand(100,5)
train_Y = np.random.choice(2, 100)
test_X = np.random.rand(10,5)
test_Y = np.random.choice(2, 10)
xg_train = xgb.DMatrix(train_X, label=train_Y)
xg_test = xgb.DMatrix(test_X, label=test_Y)
param = {}
# use softmax multi-class classification
param['objective'] = 'multi:softmax'
# scale weight of positive examples
param['eta'] = 0.1
param['max_depth'] = 6
param['silent'] = 1
param['nthread'] = 4
param['num_class'] = 2
param['gpu_id'] = 0
param['max_bin'] = 16
param['tree_method'] = 'gpu_hist'
# watchlist allows us to monitor the evaluation result on all data in the list
watchlist = [(xg_train, 'train'), (xg_test, 'test')]
num_round = 5
bst = xgb.train(param, xg_train, num_round, watchlist)
当我运行最后一行时:
bst = xgb.train(param, xg_train, num_round, watchlist)
我得到“运行时已死,自动重新启动”
有任何解决问题的想法吗?
【问题讨论】:
-
此处OP提供的代码为我在Colab上成功运行(2021年2月22日)。
标签: python gpu xgboost google-colaboratory