New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build w/ GPU but got CPU-only ver install in python (Ubuntu 16.04) #715
Comments
I think you should run |
@cttsai1985 |
@guolinke Can we check precompile first when run |
@wxchan I don't think so. I think make it independently is better. |
It's kind of counter-intuitive. I think most users don't know those |
@guolinke @wxchan
Here is some log I collected: Using pip installation:1.1 sudo pip3 install --no-binary :all: lightgbm It installed CPU-only version, so I get 1.2 sudo pip3 install lightgbm --install-option=--gpu Command "/usr/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-build-mnysq7z9/lightgbm/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-42d4zwxk-record/install-record.txt --single-version-externally-managed --compile --gpu" failed with error code 1 in /tmp/pip-build-mnysq7z9/lightgbm/ Using python3 setup.py install --precompile or --gpuBoth got the same error message: Traceback (most recent call last): OSError: /usr/local/lib/python3.5/dist-packages/lightgbm/lib_lightgbm.so: symbol clCreateCommandQueueWithProperties, version OPENCL_2.0 not defined in file libOpenCL.so.1 with link time reference 2.1 sudo python3 setup.py install --precompile running install 2.2 sudo python3 setup.py install --gpu Start to compile libarary. |
@cttsai1985 |
@huanzhang12
|
@guolinke as you wish. |
Two OpenCL libraries are installed on this system. One is provided by Nvidia (version 1.2), and another one is a generic installable client driver (ICD) OpenCL provided by OS (version 2.0). I guess the reason is that LightGBM seems to be linked to the system OpenCL (2.0), but a LD_LIBRARY_PATH setting causes the Nvidia OpenCL to be loaded first, and is incompatible with library that LightGBM was linked with. The problem with the @cttsai1985 For further debugging this problem, you can try to run |
Thanks @huanzhang12 @cttsai1985 before you using huanzhuang12's solution, you should delete .so file in |
@huanzhang12 |
Thanks @huanzhang12 @guolinke In fact, the installation instruction mentioned by @huanzhang12 is how I built LightGBM w/ GPU currently. Without addling these paths I can not pass the cmake. That is why I had already followed the issue #458 by "sudo cmake -DUSE_GPU=1 -DOpenCL_LIBRARY=/usr/local/cuda-8.0/lib64/libOpenCL.so -DOpenCL_INCLUDE_DIR=/usr/local/cuda-8.0/include/ .." to get it worked. And you've all see the results using "sudo python3 setup.py install --precompile" after successful compiled. It is there #715 (comment) Regarding to the ldd part:
|
@cttsai1985 |
@guolinke Before this time I remove LightGBM packages in python by a solution found in stacked-overflow:
Since the lightgbm lightgbm-2.0.4-py3.5.egg-info folder I would going to replace it later so I deleted both of them anyway this time. Maybe there was something mess around.
I re-installed by the following steps:
|
I successly install lightgbm gpu version like this link. but when I use lightgbm in jupyter lab, there is a ModuleNotFoundError: No module named 'lightgbm' How could I solve this problem? do you have any advise? @guolinke |
i think the reason is missing some dependencies in your jupyter, or it is not 64 bit version. |
After managed to built a LightGBM w/ GPU on Ubuntu 16.04, it asked to "Recompile with CMake option -DUSE_GPU=1'" while calling LightGBM in python 3.5. However, the binay ./LightGBM/lightgbm is able to enable GPU for computation. GPU is availabe after replacing lib_lightgbm.so in /usr/local/lib/python3.5/dist-packages/lightgbm by one ./LightGBM/ . The lib_lightgbm.so installed within python seems a CPU-only built.
The compiling LightGBM w/ GPU is following by the issue 458 by "sudo cmake -DUSE_GPU=1 -DOpenCL_LIBRARY=/usr/local/cuda-8.0/lib64/libOpenCL.so -DOpenCL_INCLUDE_DIR=/usr/local/cuda-8.0/include/ .." from #458 . Also, pip3 installation did not work for my pc.
Meanwhile, I've notice there are two different sizes of lib_lightgbm.so
2.2MB ./LightGBM/lib_lightgbm.so
1.5MB ./LightGBM/python-package/lightgbm/lib_lightgbm.so
1.5MB ./LightGBM/python-package/build/lib/lightgbm/lib_lightgbm.so
1.5MB .//usr/local/lib/python3.5/dist-packages/lightgbm/lib_lightgbm.so
It seems to me that another CPU-only lib_lightgbm.so is compiled while run "python3 setup.py install". Therefore, I decided to copy the lib_lightgbm.so and so far it works fine.
Environment info
Operating System: Ubuntu 16.04
CPU: i3-7350K / GTX 1080 (375.66)
C++/Python/R version: Python
Error Message:
[LightGBM] [Fatal] GPU Tree Learner was not enabled in this build. Recompile with CMake option -DUSE_GPU=1
Traceback (most recent call last):
File "hybrid.py", line 211, in
clf = lgb.train(params, d_train, 430)
File "/usr/local/lib/python3.5/dist-packages/lightgbm/engine.py", line 168, in train
booster = Booster(params=params, train_set=train_set)
File "/usr/local/lib/python3.5/dist-packages/lightgbm/basic.py", line 1215, in init
ctypes.byref(self.handle)))
File "/usr/local/lib/python3.5/dist-packages/lightgbm/basic.py", line 47, in _safe_call
raise LightGBMError(_LIB.LGBM_GetLastError())
lightgbm.basic.LightGBMError: b'GPU Tree Learner was not enabled in this build. Recompile with CMake option -DUSE_GPU=1'
Steps to reproduce
sudo cmake -DUSE_GPU=1 -DOpenCL_LIBRARY=/usr/local/cuda-8.0/lib64/libOpenCL.so -DOpenCL_INCLUDE_DIR=/usr/local/cuda-8.0/include/ ..
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Try OpenMP C flag = [-fopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Success
-- Try OpenMP CXX flag = [-fopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Success
-- Found OpenMP: -fopenmp
-- Looking for CL_VERSION_2_0
-- Looking for CL_VERSION_2_0 - not found
-- Looking for CL_VERSION_1_2
-- Looking for CL_VERSION_1_2 - found
-- Found OpenCL: /usr/local/cuda-8.0/lib64/libOpenCL.so (found version "1.2")
-- OpenCL include directory:/usr/local/cuda-8.0/include
-- Boost version: 1.58.0
-- Found the following Boost libraries:
-- filesystem
-- system
-- Configuring done
-- Generating done
-- Build files have been written to: /home/cttsai/DataSci/mlc/LightGBM/build
sudo make -j$(nproc)
cd ../python-package; sudo python3 setup.py install
running install
creating lightgbm/include
creating lightgbm/include/LightGBM
copying ../include/LightGBM/prediction_early_stop.h -> ./lightgbm/include/LightGBM
copying ../include/LightGBM/dataset_loader.h -> ./lightgbm/include/LightGBM
copying ../include/LightGBM/dataset.h -> ./lightgbm/include/LightGBM
copying ../include/LightGBM/application.h -> ./lightgbm/include/LightGBM
copying ../include/LightGBM/bin.h -> ./lightgbm/include/LightGBM
copying ../include/LightGBM/c_api.h -> ./lightgbm/include/LightGBM
copying ../include/LightGBM/tree.h -> ./lightgbm/include/LightGBM
copying ../include/LightGBM/export.h -> ./lightgbm/include/LightGBM
copying ../include/LightGBM/lightgbm_R.h -> ./lightgbm/include/LightGBM
copying ../include/LightGBM/meta.h -> ./lightgbm/include/LightGBM
copying ../include/LightGBM/metric.h -> ./lightgbm/include/LightGBM
copying ../include/LightGBM/network.h -> ./lightgbm/include/LightGBM
copying ../include/LightGBM/objective_function.h -> ./lightgbm/include/LightGBM
copying ../include/LightGBM/R_object_helper.h -> ./lightgbm/include/LightGBM
copying ../include/LightGBM/boosting.h -> ./lightgbm/include/LightGBM
creating lightgbm/include/LightGBM/utils
copying ../include/LightGBM/utils/pipeline_reader.h -> ./lightgbm/include/LightGBM/utils
copying ../include/LightGBM/utils/random.h -> ./lightgbm/include/LightGBM/utils
copying ../include/LightGBM/utils/array_args.h -> ./lightgbm/include/LightGBM/utils
copying ../include/LightGBM/utils/common.h -> ./lightgbm/include/LightGBM/utils
copying ../include/LightGBM/utils/log.h -> ./lightgbm/include/LightGBM/utils
copying ../include/LightGBM/utils/threading.h -> ./lightgbm/include/LightGBM/utils
copying ../include/LightGBM/utils/text_reader.h -> ./lightgbm/include/LightGBM/utils
copying ../include/LightGBM/utils/openmp_wrapper.h -> ./lightgbm/include/LightGBM/utils
copying ../include/LightGBM/feature_group.h -> ./lightgbm/include/LightGBM
copying ../include/LightGBM/tree_learner.h -> ./lightgbm/include/LightGBM
copying ../include/LightGBM/config.h -> ./lightgbm/include/LightGBM
creating lightgbm/src
creating lightgbm/src/application
copying ../src/application/application.cpp -> ./lightgbm/src/application
copying ../src/application/predictor.hpp -> ./lightgbm/src/application
copying ../src/main.cpp -> ./lightgbm/src
creating lightgbm/src/objective
copying ../src/objective/regression_objective.hpp -> ./lightgbm/src/objective
copying ../src/objective/multiclass_objective.hpp -> ./lightgbm/src/objective
copying ../src/objective/rank_objective.hpp -> ./lightgbm/src/objective
copying ../src/objective/binary_objective.hpp -> ./lightgbm/src/objective
copying ../src/objective/objective_function.cpp -> ./lightgbm/src/objective
copying ../src/objective/xentropy_objective.hpp -> ./lightgbm/src/objective
creating lightgbm/src/boosting
copying ../src/boosting/dart.hpp -> ./lightgbm/src/boosting
copying ../src/boosting/goss.hpp -> ./lightgbm/src/boosting
copying ../src/boosting/gbdt_prediction.cpp -> ./lightgbm/src/boosting
copying ../src/boosting/gbdt.h -> ./lightgbm/src/boosting
copying ../src/boosting/boosting.cpp -> ./lightgbm/src/boosting
copying ../src/boosting/gbdt.cpp -> ./lightgbm/src/boosting
copying ../src/boosting/rf.hpp -> ./lightgbm/src/boosting
copying ../src/boosting/score_updater.hpp -> ./lightgbm/src/boosting
copying ../src/boosting/prediction_early_stop.cpp -> ./lightgbm/src/boosting
creating lightgbm/src/metric
copying ../src/metric/xentropy_metric.hpp -> ./lightgbm/src/metric
copying ../src/metric/rank_metric.hpp -> ./lightgbm/src/metric
copying ../src/metric/dcg_calculator.cpp -> ./lightgbm/src/metric
copying ../src/metric/metric.cpp -> ./lightgbm/src/metric
copying ../src/metric/regression_metric.hpp -> ./lightgbm/src/metric
copying ../src/metric/multiclass_metric.hpp -> ./lightgbm/src/metric
copying ../src/metric/binary_metric.hpp -> ./lightgbm/src/metric
copying ../src/metric/map_metric.hpp -> ./lightgbm/src/metric
creating lightgbm/src/treelearner
copying ../src/treelearner/gpu_tree_learner.cpp -> ./lightgbm/src/treelearner
copying ../src/treelearner/split_info.hpp -> ./lightgbm/src/treelearner
copying ../src/treelearner/feature_parallel_tree_learner.cpp -> ./lightgbm/src/treelearner
copying ../src/treelearner/leaf_splits.hpp -> ./lightgbm/src/treelearner
copying ../src/treelearner/data_parallel_tree_learner.cpp -> ./lightgbm/src/treelearner
copying ../src/treelearner/serial_tree_learner.cpp -> ./lightgbm/src/treelearner
copying ../src/treelearner/data_partition.hpp -> ./lightgbm/src/treelearner
copying ../src/treelearner/feature_histogram.hpp -> ./lightgbm/src/treelearner
copying ../src/treelearner/tree_learner.cpp -> ./lightgbm/src/treelearner
copying ../src/treelearner/parallel_tree_learner.h -> ./lightgbm/src/treelearner
copying ../src/treelearner/voting_parallel_tree_learner.cpp -> ./lightgbm/src/treelearner
creating lightgbm/src/treelearner/ocl
copying ../src/treelearner/ocl/histogram256.cl -> ./lightgbm/src/treelearner/ocl
copying ../src/treelearner/ocl/histogram64.cl -> ./lightgbm/src/treelearner/ocl
copying ../src/treelearner/ocl/histogram16.cl -> ./lightgbm/src/treelearner/ocl
copying ../src/treelearner/gpu_tree_learner.h -> ./lightgbm/src/treelearner
copying ../src/treelearner/serial_tree_learner.h -> ./lightgbm/src/treelearner
creating lightgbm/src/io
copying ../src/io/parser.hpp -> ./lightgbm/src/io
copying ../src/io/metadata.cpp -> ./lightgbm/src/io
copying ../src/io/dense_bin.hpp -> ./lightgbm/src/io
copying ../src/io/sparse_bin.hpp -> ./lightgbm/src/io
copying ../src/io/ordered_sparse_bin.hpp -> ./lightgbm/src/io
copying ../src/io/bin.cpp -> ./lightgbm/src/io
copying ../src/io/dense_nbits_bin.hpp -> ./lightgbm/src/io
copying ../src/io/tree.cpp -> ./lightgbm/src/io
copying ../src/io/parser.cpp -> ./lightgbm/src/io
copying ../src/io/dataset_loader.cpp -> ./lightgbm/src/io
copying ../src/io/config.cpp -> ./lightgbm/src/io
copying ../src/io/dataset.cpp -> ./lightgbm/src/io
copying ../src/lightgbm_R.cpp -> ./lightgbm/src
copying ../src/c_api.cpp -> ./lightgbm/src
creating lightgbm/src/network
copying ../src/network/socket_wrapper.hpp -> ./lightgbm/src/network
copying ../src/network/linker_topo.cpp -> ./lightgbm/src/network
copying ../src/network/network.cpp -> ./lightgbm/src/network
copying ../src/network/linkers_socket.cpp -> ./lightgbm/src/network
copying ../src/network/linkers.h -> ./lightgbm/src/network
copying ../src/network/linkers_mpi.cpp -> ./lightgbm/src/network
copying ../CMakeLists.txt -> ./lightgbm/
copying ../LICENSE -> ./
Start to compile libarary.
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Try OpenMP C flag = [-fopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Success
-- Try OpenMP CXX flag = [-fopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Success
-- Found OpenMP: -fopenmp
-- Configuring done
-- Generating done
-- Build files have been written to: /home/cttsai/DataSci/mlc/LightGBM/python-package/build_cpp
Scanning dependencies of target _lightgbm
[ 3%] Building CXX object CMakeFiles/_lightgbm.dir/src/c_api.cpp.o
[ 7%] Building CXX object CMakeFiles/./LightGBM/_lightgbm.dir/src/lightgbm_R.cpp.o
[ 10%] Building CXX object CMakeFiles/_lightgbm.dir/src/application/application.cpp.o
[ 14%] Building CXX object CMakeFiles/_lightgbm.dir/src/boosting/gbdt_prediction.cpp.o
[ 17%] Building CXX object CMakeFiles/_lightgbm.dir/src/boosting/boosting.cpp.o
[ 21%] Building CXX object CMakeFiles/_lightgbm.dir/src/boosting/gbdt.cpp.o
[ 25%] Building CXX object CMakeFiles/_lightgbm.dir/src/boosting/prediction_early_stop.cpp.o
[ 28%] Building CXX object CMakeFiles/_lightgbm.dir/src/io/metadata.cpp.o
[ 32%] Building CXX object CMakeFiles/_lightgbm.dir/src/io/bin.cpp.o
[ 35%] Building CXX object CMakeFiles/_lightgbm.dir/src/io/tree.cpp.o
[ 39%] Building CXX object CMakeFiles/_lightgbm.dir/src/io/parser.cpp.o
[ 42%] Building CXX object CMakeFiles/_lightgbm.dir/src/io/dataset_loader.cpp.o
[ 46%] Building CXX object CMakeFiles/_lightgbm.dir/src/io/config.cpp.o
[ 50%] Building CXX object CMakeFiles/_lightgbm.dir/src/io/dataset.cpp.o
[ 53%] Building CXX object CMakeFiles/_lightgbm.dir/src/metric/dcg_calculator.cpp.o
[ 57%] Building CXX object CMakeFiles/_lightgbm.dir/src/metric/metric.cpp.o
[ 60%] Building CXX object CMakeFiles/_lightgbm.dir/src/objective/objective_function.cpp.o
[ 64%] Building CXX object CMakeFiles/_lightgbm.dir/src/network/linker_topo.cpp.o
[ 67%] Building CXX object CMakeFiles/_lightgbm.dir/src/network/network.cpp.o
[ 71%] Building CXX object CMakeFiles/_lightgbm.dir/src/network/linkers_socket.cpp.o
[ 75%] Building CXX object CMakeFiles/_lightgbm.dir/src/network/linkers_mpi.cpp.o
[ 78%] Building CXX object CMakeFiles/_lightgbm.dir/src/treelearner/gpu_tree_learner.cpp.o
[ 82%] Building CXX object CMakeFiles/_lightgbm.dir/src/treelearner/feature_parallel_tree_learner.cpp.o
[ 85%] Building CXX object CMakeFiles/_lightgbm.dir/src/treelearner/data_parallel_tree_learner.cpp.o
[ 89%] Building CXX object CMakeFiles/_lightgbm.dir/src/treelearner/serial_tree_learner.cpp.o
[ 92%] Building CXX object CMakeFiles/_lightgbm.dir/src/treelearner/tree_learner.cpp.o
[ 96%] Building CXX object CMakeFiles/_lightgbm.dir/src/treelearner/voting_parallel_tree_learner.cpp.o
[100%] Linking CXX shared library /home/cttsai/DataSci/mlc/LightGBM/python-package/lightgbm/lib_lightgbm.so
[100%] Built target _lightgbm
The text was updated successfully, but these errors were encountered: