-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Initial attempt at building OpenCL wheel for Windows #3051
Conversation
Looks like this iteration won't work at the very least because the |
I have improved |
I am not sure why the DLL isn't being found in tests, when I build wheel locally it has the DLL, and logs for bdist_opencl show the DLL being added. Any ideas? |
I believe that environment variables is not the best way to control installation options. Maybe there are some other methods?.. I remember we already had some proposals for Linking #2263 here as the original issue. For the general idea of having separate OpenCL wheels for Windows and possible compatibility issues ping @huanzhang12 . Also I wonder how demanded this wheel will be, given total NVIDIA (read CUDA) domination. |
As I understand it there is no specifically CUDA lightgbm at the moment, though? On Nvidia you just use OpenCL installed by CUDA? |
I can certainly change it from env variables to |
I wonder if tests are failing because there's no OpenCL runtime installed... |
Looks like tests are likely passing now for the OpenCL build, (the docs test failure are unrelated since I haven't touched docs). So remaining questions are:
|
Sorry for the inconvenience! I just re-run it.
Please give me some time to read about other possible ways. I believe we should set Lines 126 to 127 in 42ebb4e
|
Thanks, good point re device. I will be working on this again next week sometime. |
@StrikerRUS I've made the OpenCL wheel have GPU device by default. Have you decided how you feel about env variables? My feeling is that a larger |
Thanks! But it seems that now all tests are failing.
Sorry, haven't had a chance to look into this yet. |
Seems that we can make diff --git a/python-package/setup.py b/python-package/setup.py
index 73f123ba..68834dde 100644
--- a/python-package/setup.py
+++ b/python-package/setup.py
@@ -16,6 +16,60 @@ from setuptools import find_packages, setup
from setuptools.command.install import install
from setuptools.command.install_lib import install_lib
from setuptools.command.sdist import sdist
+from wheel.bdist_wheel import bdist_wheel
+
+
+class CustomBdistWheel(bdist_wheel):
+
+ user_options = bdist_wheel.user_options + [
+ ('mingw', 'm', 'Compile with MinGW'),
+ ('gpu', 'g', 'Compile GPU version'),
+ ('mpi', None, 'Compile MPI version'),
+ ('nomp', None, 'Compile version without OpenMP support'),
+ ('hdfs', 'h', 'Compile HDFS version'),
+ ('bit32', None, 'Compile 32-bit version'),
+ ('precompile', 'p', 'Use precompiled library'),
+ ('boost-root=', None, 'Boost preferred installation prefix'),
+ ('boost-dir=', None, 'Directory with Boost package configuration file'),
+ ('boost-include-dir=', None, 'Directory containing Boost headers'),
+ ('boost-librarydir=', None, 'Preferred Boost library directory'),
+ ('opencl-include-dir=', None, 'OpenCL include directory'),
+ ('opencl-library=', None, 'Path to OpenCL library')
+ ]
+
+ def initialize_options(self):
+ bdist_wheel.initialize_options(self)
+ self.mingw = 0
+ self.gpu = 0
+ self.boost_root = None
+ self.boost_dir = None
+ self.boost_include_dir = None
+ self.boost_librarydir = None
+ self.opencl_include_dir = None
+ self.opencl_library = None
+ self.mpi = 0
+ self.hdfs = 0
+ self.precompile = 0
+ self.nomp = 0
+ self.bit32 = 0
+
+ def run(self):
+ install = self.distribution.get_command_obj('install')
+ install.user_options = self.user_options
+ install.mingw = self.mingw
+ install.gpu = self.gpu
+ install.boost_root = self.boost_root
+ install.boost_dir = self.boost_dir
+ install.boost_include_dir = self.boost_include_dir
+ install.boost_librarydir = self.boost_librarydir
+ install.opencl_include_dir = self.opencl_include_dir
+ install.opencl_library = self.opencl_library
+ install.mpi = self.mpi
+ install.hdfs = self.hdfs
+ install.precompile = self.precompile
+ install.nomp = self.nomp
+ install.bit32 = self.bit32
+ bdist_wheel.run(self)
def find_lib():
@@ -98,6 +152,7 @@ def compile_cpp(use_mingw=False, use_gpu=False, use_mpi=False,
os.chdir(os.path.join(CURRENT_DIR, "build_cpp"))
logger.info("Starting to compile the library.")
+ print(boost_dir)
cmake_cmd = ["cmake", "../compile/"]
if use_gpu:
@@ -285,6 +340,7 @@ if __name__ == "__main__":
'install': CustomInstall,
'install_lib': CustomInstallLib,
'sdist': CustomSdist,
+ 'bdist_wheel': CustomBdistWheel,
},
packages=find_packages(),
include_package_data=True,
Refer to https://github.com/pypa/wheel/blob/master/src/wheel/bdist_wheel.py. Note that code above is only POC and there is a lot of room for better code, e.g. removing duplicated list of options and setting of properties. Also, we can make these changes optional to not force users install Below are some checks:
|
Replaced by #3143. |
This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this. |
Still untested on actual CI, but this should create a wheel that uses OpenCL, for #2263 based on local testing. I don't quite understand how the wheels get published from this build, but in any case that requires PyPI credentials so you'll have to finish that up.
Tasks:
lightgbm-opencl
maybe?)Someone with more access than I have will likely need to do last two items.