You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Google Colab中用GPU训练LightGBM报错:找不到build-python.sh脚本

在Google Colab中修复LightGBM GPU版安装错误

你遇到的sh: 0: cannot open ./build-python.sh: No such file错误,是因为当前LightGBM官方仓库已经移除了build-python.sh脚本,旧的安装命令不再适配最新代码结构。

以下是正确的GPU版LightGBM安装步骤:

  • 克隆仓库并进入项目根目录:
    !git clone --recursive https://github.com/Microsoft/LightGBM
    %cd LightGBM
    
  • 编译GPU支持的核心LightGBM库:
    !rm -rf build
    !mkdir build
    %cd build
    !cmake -DUSE_GPU=1 ..
    !make -j$(nproc)
    
  • 安装Python包(指定GPU预编译选项):
    %cd ../python-package
    !pip install . --install-option=--gpu --install-option=--precompile
    
  • 验证安装是否成功:
    import lightgbm as lgb
    print("LightGBM版本:", lgb.__version__)
    print("GPU支持状态:", lgb.__config__['USE_GPU'])
    
    正常情况下,USE_GPU会输出'1'或True,表示GPU功能已启用。

内容的提问来源于stack exchange,提问作者ebrahimi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 17:14:50