1

我试图按照文档中的说明进行操作

   !sudo apt-get update
   !sudo apt-get install --no-install-recommends nvidia-375
   !sudo apt-get install --no-install-recommends nvidia-opencl-icd-375 nvidia- 
    opencl-dev opencl-headers

它让我跟随错误消息

/bin/sh: 1: sudo: not found
/bin/sh: 1: sudo: not found
/bin/sh: 1: sudo: not found

然后我按照“在带有 GPU 支持的 anaconda3 中安装 LightGBM ”中的说明进行操作

!git clone --recursive https://github.com/Microsoft/LightGBM.git
!cd LightGBM/python-package
!sudo python3 setup.py install --gpu

它让我跟随错误消息

Cloning into 'LightGBM'...
remote: Counting objects: 9752, done.
remote: Compressing objects: 100% (29/29), done.
remote: Total 9752 (delta 6), reused 12 (delta 5), pack-reused 9718
Receiving objects: 100% (9752/9752), 7.68 MiB | 24.05 MiB/s, done.
Resolving deltas: 100% (6835/6835), done.
Submodule 'include/boost/compute' (https://github.com/boostorg/compute) registered for path 'compute'
Cloning into '/content/LightGBM/compute'...
remote: Counting objects: 21405, done.        
remote: Compressing objects: 100% (32/32), done.        
remote: Total 21405 (delta 20), reused 35 (delta 13), pack-reused 21354        
Receiving objects: 100% (21405/21405), 8.45 MiB | 21.85 MiB/s, done.
Resolving deltas: 100% (17364/17364), done.
Submodule path 'compute': checked out '6de7f6448796f67958dde8de4569fb1ae649ee91'
/bin/sh: 1: sudo: not found

现在我很困惑。

4

4 回答 4

2

我遇到了和你一样的问题,在尝试了一些小改动后,对我有用的是将 !cd 更改为 %cd ,然后删除 sudo

!git clone --recursive https://github.com/Microsoft/LightGBM.git
%cd LightGBM/python-package
!python3 setup.py install --gpu

但请确保您正确执行了安装步骤

!git clone --recursive https://github.com/Microsoft/LightGBM
%cd LightGBM
!mkdir build
!cd build
!cmake ./LightGBM
!make -j4

还应该安装 CMake,只需 !pip 安装它

于 2018-06-18T09:43:57.980 回答
2

我对提出的其他解决方案有一些问题。这对我有用:

  1. 在“运行时”->“更改运行时类型”下设置 GPU

  2. 然后,执行:

!git clone --recursive https://github.com/Microsoft/LightGBM
%cd /content/LightGBM
!mkdir build
!cmake -DUSE_GPU=1
!make -j$(nproc)
!sudo apt-get -y install python-pip
!sudo -H pip install setuptools pandas numpy scipy scikit-learn -U
%cd /content/LightGBM/python-package
!sudo python setup.py install --precompile
  1. 最后,import lightgbm设置'device': 'gpu'好参数,就可以开始训练模型了!
于 2019-04-21T20:02:50.157 回答
1

调整公共安装说明 WFM -- https://github.com/Microsoft/LightGBM/blob/master/docs/Installation-Guide.rst#linux

!git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM
import os
os.chdir('LightGBM')
!mkdir build
os.chdir('build')
!apt-get install cmake
!cmake ..
!make -j4

这是一个示例笔记本

于 2018-04-03T15:11:22.220 回答
0

尝试这个:

%cd /content
!rm -r /usr/local/lib/python3.6/dist-packages/lightgbm
!rm -r /content/LightGBM
!git clone --recursive https://github.com/Microsoft/LightGBM
%cd LightGBM
!mkdir build
%cd build
!cmake -DUSE_GPU=1 -DOpenCL_LIBRARY=/usr/local/cuda/lib64/libOpenCL.so.1.1 -DOpenCL_INCLUDE_DIR=/usr/local/cuda/include/ ..
!make -j$(nproc)

然后使用以下行从 python-package 目录下载 setup.py 文件:

from google.colab import files
files.download('/content/LightGBM/python-package/setup.py')

通过在第 267 行添加以下代码来编辑文件:

os.chdir('/content/LightGBM') 

将 setup.py 文件上传到 colab 并使用以下代码将其放回其文件夹:

import shutil
shutil.move("/content/setup.py", "/content/LightGBM/python-package/setup.py") 

最后,运行:

%cd /content
%cd LightGBM/python-package
!python3 setup.py install --precompile

那应该这样做。

于 2020-05-08T12:00:43.430 回答