Repository navigation
[docs] update Python-package installation guide - #6767
Conversation
| --config-settings=cmake.define.USE_GPU=ON \ | ||
| --config-settings=cmake.define.OpenCL_INCLUDE_DIR="/usr/local/cuda/include/" \ | ||
| --config-settings=cmake.define.OpenCL_LIBRARY="/usr/local/cuda/lib64/libOpenCL.so" | ||
| pip install lightgbm --no-binary lightgbm --config-settings=cmake.define.USE_GPU=ON --config-settings=cmake.define.OpenCL_INCLUDE_DIR="/usr/local/cuda/include/" --config-settings=cmake.define.OpenCL_LIBRARY="/usr/local/cuda/lib64/libOpenCL.so" |
There was a problem hiding this comment.
We cannot predict which shell user is using. For example, to split long line in PowerShell, ` char should be used. So for better UX I think it better to provide universal copy-pastable commands.
jameslamb
left a comment
There was a problem hiding this comment.
Thanks for this! I left some suggestions for your consideration.
|
|
||
| | | ||
|
|
||
| Use LightGBM with Matplotlib and Graphviz |
There was a problem hiding this comment.
| Use LightGBM with Matplotlib and Graphviz | |
| Use LightGBM Plotting Capabilities |
For the other blocks, "Use LightGBM with {library}" is a helpful title, because that's how users are likely to be thinking about it. e.g. "I have a Dask cluster, how do I use LightGBM with Dask".
For plotting, I don't think that's true. I suspect that for most users, they are not thinking "how do I use LightGBM with graphviz?" and instead are just interested in "how do I visualize the structure of my LightGBM models?".
In other words... the fact that these functions happen to use matplotlib and graphviz isn't central to their value.
Would you consider renaming this?
|
|
||
| .. code:: sh | ||
|
|
||
| # in sh.exe, git bash, or other Unix-like shell |
| conda install -c conda-forge lightgbm | ||
|
|
||
| These are precompiled packages that are fast to install. | ||
| Use them instead of ``pip install`` if any of the following are true: |
There was a problem hiding this comment.
I do think that the conda-forge packages offer a lot of benefits. But it's not as clear as one approach being "recommended" and the other being "not recommended".
Situations where conda-forge's lightgbm should be preferred:
- you want to use the CUDA version (ref: CUDA builds should depend on __cudaΒ conda-forge/lightgbm-feedstock#58)
- you want to run on the
ppc4learchitecture - you want to use many libraries that all rely on OpenMP at the same time (ref: [python-package] SegFault on MacOS when pytorch is installedΒ #6595)
- you want to (or are required to!) use conda for non-LightGBM reasons
Situations where pip install lightgbm should be preferred
- you want to customize the build (e.g. use a different Boost version, build a variant like the MPI package, compile with debug symbols, etc.)
- you want to (or are required to!) use
pipfor non-LightGBM reasons
All that said... I'm indifferent about the order. If you want to put conda before pip, that's fine. But at this point, I don't think we should say that one is "preferred" or "recommended".
| # OpenCL include directory. | ||
| # --opencl-library=FILEPATH | ||
| # Path to OpenCL library. | ||
| # --sanitizers=LIST_OF_SANITIZERS |
There was a problem hiding this comment.
I'm not excited about adding --sanitizers, --debug, and --nohomebrew to this script when no one has asked for them.
This build-python.sh script is already more complex than I'm comfortable with and is duplicating functionality that'd be better-handled by CMake.
Rather than trying to have a flag here for every option() in this project's CMake, I think we should just rely on documentation describing how to use --precompile to use a shared library built with whatever customizations you want.
I'd love to put our energy into instead working towards eliminating this script eventually with heavier use of CMake + all of the improvements that have gone into scikit-build-core over the last year (some of which I sort of describe in #6774).
What do you think?
| Build without Searching in Homebrew Folders for Dependencies on macOS | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| .. code:: sh | ||
|
|
||
| pip install lightgbm --no-binary lightgbm --config-settings=cmake.define.USE_HOMEBREW_FALLBACK=OFF | ||
|
|
||
| Use this option to stop looking into Homebrew standard folders for finding dependencies (e.g. OpenMP) during the build on macOS. | ||
|
|
||
| | | ||
|
|
There was a problem hiding this comment.
| Build without Searching in Homebrew Folders for Dependencies on macOS | |
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
| .. code:: sh | |
| pip install lightgbm --no-binary lightgbm --config-settings=cmake.define.USE_HOMEBREW_FALLBACK=OFF | |
| Use this option to stop looking into Homebrew standard folders for finding dependencies (e.g. OpenMP) during the build on macOS. | |
| | |
I think we should omit this section. If you're using pip install (not pip wheel or python -m build) like this, then you're not building a package for redistribution... you're just installing one for runtime use on the same system.
The OpenMP found at build time will become the first RPATH entry in lib_lightgbm.dylib, and so it'll be found when you run import lightgbm.
As long as that library is still there later, it doesn't matter whether you later brew install libomp on the same system.
There was a problem hiding this comment.
I just do not think we need 1 paragraph-size section like this matching every option() in CMakeLists.txt. It creates duplication across the project and and adds to the size of the doc, which I think is intimidating for some users.
I think it is fine to only have specific sections for:
- build variations that we expect to be popular
- build variations that require significant explanation (e.g., all the customizations options for
USE_GPU=ON))
There was a problem hiding this comment.
I feel the same way about other new sections below... do not think we need to have a separate section in this doc describing how to build the Python package with sanitizers or with USE_DEBUG enabled.
| plotting = [ | ||
| "graphviz", | ||
| "matplotlib" | ||
| ] |
There was a problem hiding this comment.
Agree! Every optional dependency should have an extra. Totally support this.
| [tool.scikit-build.cmake] | ||
| version = "CMakeLists.txt" | ||
| build-type = "Release" | ||
|
|
||
| [tool.scikit-build.cmake.define] | ||
| __BUILD_FOR_PYTHON = "ON" | ||
|
|
There was a problem hiding this comment.
What is the benefit of moving these things down here? Are the equivalent fields in [tool.scikit-build] deprecated?
There was a problem hiding this comment.
Huh, these nested fields are identical, I simply don't know how to specify nested mapping tool.scikit-build.cmake.define in existing setup π¬
And I think that
[tool.scikit-build.cmake.define]
__BUILD_FOR_PYTHON = "ON"
some_new_option = "value"is more readable than
[tool.scikit-build]
cmake.define.__BUILD_FOR_PYTHON = "ON"
cmake.define.some_new_option = "value"There was a problem hiding this comment.
I agree with you about that, I'd expected that this form would work:
[tool.scikit-build]
cmake.define = [
"__BUILD_FOR_PYTHON=ON",
"some_new_option=value"
]But when I search around on GitHub, I don't see any examples like that: https://github.com/search?q=%22cmake.define%22+language%3ATOML&type=code&p=1
Let's leave this as you have it in the PR, I like it.
|
@jameslamb I think I addressed all your comments. Please give another look at this PR. |
jameslamb
left a comment
There was a problem hiding this comment.
This looks great to me! I think all of my initial comments have been addressed. Thank you very much for all of your hard work, especially for testing all of these different installation methods.
|
This pull request has been automatically locked since there has not been any recent activity since it was closed. |
Every installation method and some their combinations were tested with the help of our CI (Appveyor and GitHub Actions). Everything is working except
--sanitizersflag: package installation is successful but it's import fails:log:
I'm not sure we ever checked even building LightGBM (not
testlightgbm) with sanitizers.