首页 > 解决方案 > 在支持 GPU 的 iMac M1 上安装 XGBoost

问题描述

我目前为在我的 M1 iMac 计算机上运行 XGBoost 编写了一些脚本。我已经在 conda-forge 中安装了 XGBoost,如下所示:

...
wheel                     0.37.0             pyhd8ed1ab_1    conda-forge
xgboost                   1.5.0            py39ha480839_0    conda-forge
xz                        5.2.5                h642e427_1    conda-forge
...

但我得到这个错误,不知道为什么:

Traceback (most recent call last):
  File "/Volumes/XXXXDrive/ProjectDrive/Project/Project.py", line 195, in
    xgb_model.fit(dtrainx, dtrainy)
  File "/Users/XXXX/miniforge3/lib/python3.9/site-packages/xgboost/core.py", line 506, in inner_f
    return f(**kwargs)
  File "/Users/XXXX/miniforge3/lib/python3.9/site-packages/xgboost/sklearn.py", line 789, in fit
    self._Booster = train(
  File "/Users/XXXX/miniforge3/lib/python3.9/site-packages/xgboost/training.py", line 188, in train
    bst = _train_internal(params, dtrain,
  File "/Users/XXXX/miniforge3/lib/python3.9/site-packages/xgboost/training.py", line 81, in _train_internal
    bst.update(dtrain, i, obj)
  File "/Users/XXXX/miniforge3/lib/python3.9/site-packages/xgboost/core.py", line 1680, in update
    _check_call(_LIB.XGBoosterUpdateOneIter(self.handle,
  File "/Users/XXXX/miniforge3/lib/python3.9/site-packages/xgboost/core.py", line 218, in _check_call
    raise XGBoostError(py_str(_LIB.XGBGetLastError()))
xgboost.core.XGBoostError: [01:00:46] /Users/runner/miniforge3/conda-bld/xgboost-split_1635105055642/work/src/gbm/../common/common.h:157: XGBoost version not compiled with GPU support.
Stack trace:
  [bt] (0) 1   libxgboost.dylib                    0x000000011f9418b0 dmlc::LogMessageFatal::~LogMessageFatal() + 124
  [bt] (1) 2   libxgboost.dylib                    0x000000011f9bf708 xgboost::gbm::GBTree::ConfigureUpdaters() + 464
  [bt] (2) 3   libxgboost.dylib                    0x000000011f9bf248 xgboost::gbm::GBTree::Configure(std::__1::vector<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > > const&) + 1008
  [bt] (3) 4   libxgboost.dylib                    0x000000011f9d91dc xgboost::LearnerConfiguration::Configure() + 1076
  [bt] (4) 5   libxgboost.dylib                    0x000000011f9d951c xgboost::LearnerImpl::UpdateOneIter(int, std::__1::shared_ptr<xgboost::DMatrix>) + 144
  [bt] (5) 6   libxgboost.dylib                    0x000000011f945b58 XGBoosterUpdateOneIter + 164
  [bt] (6) 7   libffi.dylib                        0x0000000199014050 ffi_call_SYSV + 80
  [bt] (7) 8   libffi.dylib                        0x000000019901c9e4 ffi_call_int + 948
  [bt] (8) 9   _ctypes.cpython-39-darwin.so        0x0000000113f8c744 _ctypes_callproc + 1236

我猜我目前拥有的 xgboost 不是 GPU 支持,而只是 CPU 支持。我predictor的是一个gpu_predictor。但是有谁知道如何检查我是否有 GPU 版本?或者至少我如何在我的 M1 iMac 上安装 GPU 版本的 XGBoost?谢谢!

标签: macosgpuxgboostapple-m1xgbregressor

解决方案


火,

xgb 不支持 Apple M1 GPU。您可以在 Github 上查看问题: https ://github.com/dmlc/xgboost/issues/6408

我不希望 xgb 或 lgbm 很快支持 Apple GPU,这是非常不幸的。

干杯


推荐阅读