Skip to content

WIP: hack to make nipy compile on linux with mkl #293

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

Closed
wants to merge 3 commits into from

Conversation

satra
Copy link
Member

@satra satra commented Sep 16, 2013

This is a WIP to allow nipy to be compiled under anaconda on linux with mkl support. unfortunately numpy.get_info() returns libraries that are not allowed to be distributed with mkl (mkl_lapack95_lp64).

This ideally should be fixed in numpy, but this hack allows nipy to compile.

In [3]: np.show_config()
lapack_opt_info:
    libraries = ['mkl_lapack95_lp64', 'mkl_intel_lp64', 'mkl_intel_thread', 'mkl_core', 'iomp5', 'pthread']
    library_dirs = ['/software/python/anaconda/envs/resting/lib']
    define_macros = [('SCIPY_MKL_H', None)]
    include_dirs = ['/software/python/anaconda/envs/resting/include']
blas_opt_info:
    libraries = ['mkl_intel_lp64', 'mkl_intel_thread', 'mkl_core', 'iomp5', 'pthread']
    library_dirs = ['/software/python/anaconda/envs/resting/lib']
    define_macros = [('SCIPY_MKL_H', None)]
    include_dirs = ['/software/python/anaconda/envs/resting/include']
lapack_mkl_info:
    libraries = ['mkl_lapack95_lp64', 'mkl_intel_lp64', 'mkl_intel_thread', 'mkl_core', 'iomp5', 'pthread']
    library_dirs = ['/software/python/anaconda/envs/resting/lib']
    define_macros = [('SCIPY_MKL_H', None)]
    include_dirs = ['/software/python/anaconda/envs/resting/include']
blas_mkl_info:
    libraries = ['mkl_intel_lp64', 'mkl_intel_thread', 'mkl_core', 'iomp5', 'pthread']
    library_dirs = ['/software/python/anaconda/envs/resting/lib']
    define_macros = [('SCIPY_MKL_H', None)]
    include_dirs = ['/software/python/anaconda/envs/resting/include']
mkl_info:
    libraries = ['mkl_intel_lp64', 'mkl_intel_thread', 'mkl_core', 'iomp5', 'pthread']
    library_dirs = ['/software/python/anaconda/envs/resting/lib']
    define_macros = [('SCIPY_MKL_H', None)]
    include_dirs = ['/software/python/anaconda/envs/resting/include']

@matthew-brett
Copy link
Member

Oh dear - yes - this is terribly ugly.

Is there a way to make this change once?

@alexis-roche - any comments here.

Satra - did you submit some pull request or issue to numpy?

@alexis-roche
Copy link
Member

My only comment is that we should now seriously think of cutting the lapack-dependent branch from nipy as I believe it's mainly experimental stuff. I would suggest to create a nipy-labs project to host that stuff. I could start doing that in a couple of weeks.

@matthew-brett
Copy link
Member

That would be excellent. I wonder if there is time to get that done before the paper deadline, so we can release?

@alexis-roche
Copy link
Member

I started here:
https://github.com/alexis-roche/nipy/tree/remove-labs

Also I created a new project called nipy-labs (I couldn't do it on github.com/nipy due to insufficient permission, but the idea would be to have the upstream branch there):
https://github.com/alexis-roche/nipy-labs

It looks quite trivial. You might want to clean up setup files for ugly lapack-related installation fixes. Also, I am not sure what to do with the docs since I don't use sphinx.

@satra
Copy link
Member Author

satra commented Sep 27, 2013

@matthew-brett - i didn't have time to track down the core issues - the info is the same on linux or osx, but it compiles fine without this hack on osx but not on linux. i'll see if i can get to it over this weekend. in either case though, i don't think that particular library should be exposed by numpy. i'll post an issue on numpy as well once i have a better understanding.

@matthew-brett
Copy link
Member

Alexis - where are we on this one?

@matthew-brett
Copy link
Member

Alexis - can I close this one?

@alexis-roche
Copy link
Member

Sorry for being so slow to respond. Yes, I think we can close this one although we probably agree that it's a short term fix. I am not sure anymore what we have (or have not) decided re the Lapack dependence in the long run - maybe worthwhile clarifying again.

@satra
Copy link
Member Author

satra commented May 26, 2014

@mwaskom - see this thread - this hack works, but i believe alexis had a better solution - i'm sorry i've lost track of this. but this issue is biting anyone with anaconda+accelerate on any platform currently. it can be tracked to how numpy returns site info.

there is also a current scikit-learn thread on how to compile projects dependent on scipy/numpy without resorting to compiling with libraries and instead to directly use the function pointers from scipy/numpy (not completely applicable here, but mentioning it).

@mwaskom
Copy link
Member

mwaskom commented May 27, 2014

Thanks Satra, So there's currently no way to install nipy in an environment with MKL numpy/scipy? That's...frustrating.

@satra
Copy link
Member Author

satra commented May 27, 2014

to be specific, i think this is an issue with conda+accelerate - i don't know about canopy.

however, if you compiled numpy/scipy with MKL yourself, you would have access to the libraries and this shouldn't be an issue.

@matthew-brett
Copy link
Member

@alexis - where are we with this one?

@mwaskom
Copy link
Member

mwaskom commented May 27, 2014

I don't think that's the right Alexis :)

@matthew-brett
Copy link
Member

Oops

@alexis-roche ..

* upstream/master: (115 commits)
  RF: make .travis.yml use travis Python and wheels
  RF: allow for run-to-run difference in SVD results
  BF: object deletion for Windows file delete errors
  BF: set matplotlib backend for realign command
  BF: deal with random signs for PCA on Windows
  BF: make use of dot compatible with numpy < 1.5
  RF: decorator to insist on matplotlib agg backend
  BF: prepare use of print for Python 3
  BF: agg mpl backend for tests writing png files
  TST: Save the result in the temp directory in which this runs.
  Simplify
  BF: Slowly understanding argparse.
  BF: Output file handling.
  BF: Resolve error handling logic.
  DOC: Define the output of aff2rot_zooms.
  ENH: support case n_cuts=1
  ENH: removed useless line returns
  ENH: removed useless line returns
  ENH: reverted changes to nipy/COMMIT_INFO.txt
  ENH: removed empty line in list comprehension
  ...
@mwaskom
Copy link
Member

mwaskom commented Nov 5, 2014

Any progress here?

@matthew-brett
Copy link
Member

@alexis-roche - any thoughts?

We might be suffering from the fact that none of Alexis Bertrand or I use conda.

@alexis-roche
Copy link
Member

Hi,

As far as I understand, it was a blas/lapack-linking issue, which should now be fixed with the current master version that builds a lapack-lite distribution from C sources rather than trying to link with the system blas/lapack...

https://github.com/nipy/nipy/blob/master/nipy/labs/setup.py

At some point, we need to switch to the scipy mechanism that allows to get C pointers to lapack functions... does that work on conda?

@satra
Copy link
Member Author

satra commented Nov 6, 2014

@alexis-roche - the issue is with get_info that comes from numpy - this issue only arises when we have numpy compiled for efficiency with MKL. so that script will simply detect the lapack that MKL provides and try to compile with that. however, numpy get_info detects a few libraries that cannot be used in the linking step because they are not distributed. so we can't compile.

as you said one is to use the c pointers to the lapack funcs. this works across platforms and distributions and would be the ideal solution.

@alexis-roche
Copy link
Member

@satra - Right, but the result of get_info should not affect the compilation by default. As per the current master version, the lapack-lite distribution is compiled by default, which does not involve any external linking, unless the relevant nipy.labs setup file is edited to toggle the WANT_LAPACK_LINKING global variable from False to True, see:

https://github.com/nipy/nipy/blob/master/nipy/labs/setup.py

Am I missing something? Anyway, this is all confusing... Sounds like we should proceed soon with the new approach.

@satra
Copy link
Member Author

satra commented Nov 6, 2014

just tried compiling current master - and that library info comes from the get_info function:

gcc -bundle -undefined dynamic_lookup -L/software/anaconda/envs/devpype/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.5-x86_64-2.7/build/src.macosx-10.5-x86_64-2.7/nipy/labs/bindings/linalg.o -L/software/anaconda/envs/devpype/lib -L/software/anaconda/envs/devpype/lib -Lbuild/temp.macosx-10.5-x86_64-2.7 -lcstat -lmkl_lapack95_lp64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -o build/lib.macosx-10.5-x86_64-2.7/nipy/labs/bindings/linalg.so
gcc: warning: couldn’t understand kern.osversion ‘14.0.0
ld: library not found for -lmkl_lapack95_lp64
collect2: error: ld returned 1 exit status
gcc: warning: couldn’t understand kern.osversion ‘14.0.0
ld: library not found for -lmkl_lapack95_lp64
collect2: error: ld returned 1 exit status
error: Command "gcc -bundle -undefined dynamic_lookup -L/software/anaconda/envs/devpype/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.5-x86_64-2.7/build/src.macosx-10.5-x86_64-2.7/nipy/labs/bindings/linalg.o -L/software/anaconda/envs/devpype/lib -L/software/anaconda/envs/devpype/lib -Lbuild/temp.macosx-10.5-x86_64-2.7 -lcstat -lmkl_lapack95_lp64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -o build/lib.macosx-10.5-x86_64-2.7/nipy/labs/bindings/linalg.so" failed with exit status 1

@alexis-roche
Copy link
Member

OK, that's weird. Well, it probably comes line 79 in the above mentioned setup.py file where we provide the lapack_info even though it's not needed if WANT_LAPACK_LINKING==False. I'll issue a PR tomorrow to try and fix this, please let me know if it works.

@matthew-brett
Copy link
Member

Michael, Satra - have y'all got a desktop that could run as a buildbot and that compiles using conda, so we can continue to test this?

@alexis-roche
Copy link
Member

@satra @mwaskom

Please checkout
#326

* master:
  hrf_model was declared but never used
  do not execute non-executable, provide shebang for executable script
  minor typos
  Update design_matrix.py
@matthew-brett
Copy link
Member

@satra - OK to close this one?

@satra satra closed this Sep 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants