ntucllab / libact

Pool-based active learning in Python
http://libact.readthedocs.org/
BSD 2-Clause "Simplified" License
777 stars 175 forks source link

Windows Support #152

Open cmoscardi opened 5 years ago

cmoscardi commented 5 years ago

Hi, I'm trudging away on Windows support (with very minimal knowledge of Windows environments) here: https://github.com/cmoscardi/libact (just on master).

If anyone else is interested in this, and knows a thing or two about compiling stuff on Windows (especially getting LAPACK to work, my current headache), please do let me know! Comment here or raise an issue on my fork, and we can talk more.

cmoscardi commented 5 years ago

And, for reference, the most recent error is the following, during compilation of the variance_reduction.c file. From this build (and you can see build progress here too): https://ci.appveyor.com/project/cmoscardi/libact/build/1.0.37

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include\cstdlib(19): error C2061: syntax error: identifier 'noexcept'

According to this post, this should be compiled as C++ code? But that leads to a circular error of some sort where I'm told I'm missing dgesvd_, which may or may not be solvable by including clapack... but then there are multiple definitions of the same variable.

Oh, also worth noting that I had to follow the advice of this post to deal with that complex.h issue (which is also brought up in a couple of the issues on this repo where people are trying to build with Windows).

yangarbiter commented 5 years ago

variance_reduction.c is actually a file generated from variance_reduction.pyx, I don't think you should change the file.

Are you able to follow #118 for building the package?

cmoscardi commented 5 years ago

Wait sorry, where is that .pyx file? I don't see it in the repo.

As for #118, it looks like they're stuck in approximately the same place as I am. Basically, getting lapacke installed in some way, shape, or form seems to be a challenge.

With that said, I think I've gotten closer (notably, this has included modifying the variance_reduction.c file), and now need to figure out why something in LAPACK itself (or maybe the entirety of LAPACK) isn't linking correctly.

variance_reduction.obj : error LNK2001: unresolved external symbol dgesvd_

Full build output: here variance_reduction.c file at the relevant commit: here

yangarbiter commented 5 years ago

Oh sorry, my bad, the variance_reduction.c is correct.

I think the key problem might be this line https://ci.appveyor.com/project/cmoscardi/libact/build/1.0.60#L124

The extra_link_args in setup.py is set for linux system https://github.com/yangarbiter/libact/blob/master/setup.py#L28

Link your C application built with MSVC with the BLAS,LAPACK and LAPACKE libraries (the lib files) you just downloaded. In your project properties, change the properties "Linker > General > Additional Library Directory" to tell Visual Studio where the libraries are, and also add the name of your BLAS, LAPACK and LAPACKE libraries in "Linker > Input > Additional Dependencies", just put "liblapacke.lib;liblapack.lib;libblas.lib"

You may have to change the setup.py file accordingly

cmoscardi commented 5 years ago

Yep, it was indeed explicitly linking that. Now, building completes, but the built .pyd file still cannot be found for some reason.

This is likely a simple issue, but again, I'm just not particularly experienced with the Windows build process, so any help would be appreciated.

Build output: https://ci.appveyor.com/project/cmoscardi/libact/build/1.0.73#L345

Remarks:

  1. Starting here, https://github.com/cmoscardi/libact/blob/master/appveyor.yml#L78 , I've changed the script to first run setup.py build, then setup.py test, to confirm that the built files exist.

  2. According to what I'm seeing on the internet, I should just have to change PYTHONPATH to include the .pyd file's location, but as you can see verified here, the PYTHONPATH includes a location where that .pyd file lives, and python still can't find it... https://ci.appveyor.com/project/cmoscardi/libact/build/1.0.73#L184

  3. Furthermore, the libblas, liblapack, liblapacke DLL files are on the PATH... see here: https://ci.appveyor.com/project/cmoscardi/libact#L83 (and the files themselves are downloaded around line 24 in this output)

cmoscardi commented 5 years ago

Update: I've gotten it to build. Take a look at this, though -- many tests are failing.

https://ci.appveyor.com/project/cmoscardi/libact

Notably, scikit-learn was giving tons of error output about some default parameters (see https://github.com/scikit-learn/scikit-learn/issues/9997 ) into the logistic regression model (as well as an SVM parameter), so I changed those... here's the commit showing the change in the logit model wrapper class with the current defaults. https://github.com/cmoscardi/libact/commit/991fc8777254bb179be1485735f3951804b4ccfa