jrs65 / scalapy

A python wrapper around ScaLAPACK
32 stars 12 forks source link

scalapy in Python 3 #21

Closed vincentmr closed 8 years ago

vincentmr commented 8 years ago

In case someone wonders how to install scalapy for a Python 3 distribution, the following modifications worked for me. @ Run 2to3 over the entire scalapy directory: <2to3 -f all -n -w scalapy-master> @ Change setup.py as follows: In runcommand, replace <<<return c[0] by

c = c[0] if type(c) is bytes: c = c.decode() return c @ Change scalapy/core.py as follows: Replace <<<import blacs <<<import mpi3util by from . import blacs from . import mpi3util @ Change scalapy/blacs.pyx as follows: The variable order is expected to be a bytes instead of a string. Replace instances of <<<"Row" by b"Row"

jrs65 commented 8 years ago

@vincentmr Thanks for the tips here. It doesn't sound like it'll be very hard to make it compatible with both python 2 and 3 using six (or similar). I haven't had a lot of time to spend on scalapy recently, but hopefully I'll be able to spend a bit more time soon.

jrs65 commented 8 years ago

@vincentmr I've just finished the port to Python 3 (see #24). I'd be grateful if you had a few moment to check it out before I merge it into master.

vincentmr commented 8 years ago

@jrs65 I am really a beginner in Python, so I would not catch a bug just by staring at the changes. I can see that everything in my kludgy solution got (elegantly) covered and more. I will install it on two clusters (one MKL, one Netlib) and try out some examples next week end. Thank you for maintaining the code.

vincentmr commented 8 years ago

@jrs65 Hi, I have installed scalapy on two systems (Colosse and Guillimin http://www.calculquebec.ca/en/resources/compute-servers/guillimin) using both the MKL and Netlib distributions of ScaLAPACK. I was able to test scalapy successfully using the (Colosse, MKL) combination. The (Guillimin, MKL) combination can run the tests, but cannot pass them (results are off). When I try using Netlib's distribution, I get errors such as:

ImportError: /home/vincentm/.python-eggs/scalapy-0.0.0-py2.7-linux-x8664.egg-tmp/scalapy/lowlevel/pblas.so: undefined symbol: cgemv

All of this holds true if I switch to Python 2.7.10, and hence the problems should not originate from the Python 3 support changes. I thus think you can safely merge the branch to the trunk. I was wondering if you could provide some hints on how to build the Netlib ScaLAPACK so that scalapy works. For instance, did you make it work with a static or shared library build?

jrs65 commented 8 years ago

@vincentmr you generally need to use a shared library version of ScaLAPACK. I'd try that one if you're not using it already.

As for the issues with Guillimin, can you let me know what modules you were using? I have an account on guillimin, so it would probably be a good idea for me to figure out what is going wrong.

vincentmr commented 8 years ago

Hi, MKL build: using the new Lmod/EasyBuild-based module system, I load the iomkl package since the only available Python 3 environments require it. Then I load either Python/3.4.3 or Python/3.5.0 (case-sensitive) and run the scalapy installer. Netlib build: I load the iomkl package and Python/3.5.0, and build ScaLAPACK from source. I then modify the setup.py file to link the library that I want. (I tried a few other things, but none of them worked). A colleague of mine is working on a Docker container. I could send it to you when it works if you are interested. Bests, Vincent

On Fri, Jan 8, 2016 at 1:54 PM, Richard Shaw notifications@github.com wrote:

@vincentmr https://github.com/vincentmr you generally need to use a shared library version of ScaLAPACK. I'd try that one if you're not using it already.

As for the issues with Guillimin, can you let me know what modules you were using? I have an account on guillimin, so it would probably be a good idea for me to figure out what is going wrong.

— Reply to this email directly or view it on GitHub https://github.com/jrs65/scalapy/issues/21#issuecomment-170090607.

ahappydog commented 8 years ago

Hi, what's next about netlib? I compiled a shared library of scalapack, I still fail to import scalapy. It says,

import scalapy Traceback (most recent call last): File "", line 1, in File "/home/xhzheng/python/scalapy-master/scalapy/init.py", line 12, in from .core import * File "/home/xhzheng/python/scalapy-master/scalapy/core.py", line 43, in from . import blacs ImportError: cannot import name 'blacs'

Do you have any hints?

ahappydog commented 8 years ago

And this:

import scalapy Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.4/dist-packages/scalapy-0.0.0-py3.4-linux-x86_64.egg/scalapy/init.py", line 13, in from .routines import * File "/usr/local/lib/python3.4/dist-packages/scalapy-0.0.0-py3.4-linux-x86_64.egg/scalapy/routines.py", line 26, in from . import lowlevel as ll File "/usr/local/lib/python3.4/dist-packages/scalapy-0.0.0-py3.4-linux-x86_64.egg/scalapy/lowlevel/init.py", line 140, in from . import pblas as _pblas ImportError: /usr/local/lib/python3.4/dist-packages/scalapy-0.0.0-py3.4-linux-x8664.egg/scalapy/lowlevel/pblas.cpython-34m.so: undefined symbol: ssyr2k

jrs65 commented 8 years ago

@ahappydog It looks like an issue linking against the compiled version of ScaLAPACK and BLAS. How did you compile ScaLAPACK? Did you link scalapy against the same version of BLAS you compiled ScaLAPACK against.

vincentmr commented 8 years ago

@ahappydog I get the same error when I compile my own shared ScaLAPACK library. Are you also trying to install it on Guillimin?

xhzheng commented 8 years ago

I failed for atlas, netlib, openblas. I can run numpy and scipy with openblas, but it does not work for scalapy. I comiple the scalapack.so with the following changes in SLmake.inc: FCFLAGS = -O3 -fPIC -shared CCFLAGS = -O3 -fpic -shared SCALAPACKLIB = libscalapack.so BLASLIB = /usr/local/lib/libopenblas.so LAPACKLIB = /usr/local/lib/libopenblas.so and in SRC/Makefile: CFLAGS is changed to CCFLAGS then make.

xhzheng commented 8 years ago

I install it in Ubuntu 14.04, not on Guillimin.

vincentmr commented 8 years ago

@xhzheng In order to build ScaLAPACK as a shared library, I think you need to use CMake and set BUILD_SHARED_LIBS = ON.

xhzheng commented 8 years ago

Could you give some more details? I am not familiar with CMake. What files should be added or changed in scalapack package to build with cmake, please?

vincentmr commented 8 years ago

@xhzheng You need CMake installed. First, untar scalapack-2.0.2.tgz and jump into the directory scalapack-2.0.2. In CMakeLists.txt, there is an option BUILD_SHARED_LIBS. It is set to OFF by default. You must change it to ON. Then cmake . and then make.

ultimanet commented 8 years ago

@xhzheng I managed to install scalapy on top of my own install of scalapack on an Ubuntu 14.04 following this tutorial: http://aragorn.pb.bialystok.pl/~mars/tutorial/scalapack/

In order to compile with gcc 4.something you need to add this to the Bmake.inc:

_With gcc 4.8.4 I got an error when compiling BLACS: mpif-common.h coud not be found… The solution was to set the F77FLAGS in the Bmake.inc to: F77FLAGS = $(F77NOOPTFLAGS) -O -I/usr/include/openmpi

ultimanet commented 8 years ago

Attached you find my Bmake.inc, make.inc and SLmake.inc files.

2015 - Scalapack install.zip

xhzheng commented 8 years ago

@vincentmr I have compiled the netlib (blas, lapack) and scalapack with cmake. Now scalapy is successfully installed. When I import scalapy from python, no error appears. BTW, I use anaconda3.

@ultimanet Thank you very much for your scheme. I will also try it.

xhzheng commented 8 years ago

@vincentmr @jrs65 I have compiled shared library of scalapack with netlib and openblas by cmake on Ubuntu 14.04. The tests are all successful. Thank you very much.

xhzheng commented 8 years ago

@jrs65 Hi, is there a possibility to install scalapy with mpich2? Or could you work out a version that supports mpich2, please? Thank you very much.