我正在使用Google上的CUML 0.10.0库中的随机森林回归模型,并且在获取模型预测时遇到了困难。在模型训练成功结束后,我使用(.predict)方法对一个非常大的数组(41697600,11)进行推理。但是,我收到以下错误:
TypeError: GPU predict model only accepts float32 dtype as input, convert the data to float32 or use the CPU predict with `predict_model='CPU'`.即使将输入numpy数组的dtype转换为float32并在预测方法中指定预测模型=‘CPU’参数,错误仍然存在。
这是供您参考的使用代码:
array=(X_test.values).astype('float32')
predictions = cuml_model.predict(array, predict_model='CPU',output_class=False, algo='BATCH_TREE_REORG')示范摘要:
<bound method RandomForestRegressor.print_summary of RandomForestRegressor(n_estimators=10, max_depth=16, handle=<cuml.common.handle.Handle object at 0x7fbfa342e888>, max_features='auto', n_bins=8, n_streams=8, split_algo=1, split_criterion=2, bootstrap=True, bootstrap_features=False, verbose=False, min_rows_per_node=2, rows_sample=1.0, max_leaves=-1, accuracy_metric='mse', quantile_per_tree=False, seed=-1)>发布于 2019-11-22 18:21:52
这个错误消息非常令人困惑。我认为这是失败的,因为训练是在float64,而不是预测。因此,如果您使用float32进行培训,那么这一切都应该是可行的。目前优化的GPU预测实现只支持float32模型。您应该能够回到缓慢的CPU预测,但这个异常正在阻止它。
我将此作为一个bug提交,我们将尝试在即将发布的版本中得到一个修复。请随时跟随,或添加任何额外的问题等:https://github.com/rapidsai/cuml/issues/1406
发布于 2021-10-31 17:59:21
对于int64,我得到了相同的错误,但是float64显示了错误。因此,任何有相同问题的人都可以简单地将int64转换为float32或int32。
https://stackoverflow.com/questions/58999284
复制相似问题