15

I have a piece of code which computes the Helmholtz-Hodge Decomposition. I've been running on my Mac OS Yosemite and it was working just fine. A month ago, however, my Mac got pretty slow (it was really old), and I opted to buy a new notebook (Windows 8.1, Dell).

After installing all Python libs and so on, I continued my work running this same code (versioned in Git). And then the result was pretty weird, completely different from the one obtained in the old notebook.

For instance, what I do is to construct to matrices a and b(really long calculus) and then I call the solver:

s = numpy.linalg.solve(a, b)

This was returning a (wrong, and different of the result obtained in my Mac, which was right).

Then, I tried to use:

s = scipy.linalg.solve(a, b)

And the program exits with code 0 but at the middle of it. Then, I just made a simple test of:

print 'here1'
s = scipy.linalg.solve(a, b)
print 'here2'

And here2 is never printed.

I tried:

print 'here1'
x, info = numpy.linalg.cg(a, b)
print 'here2'

And the same happens.

I also tried to check the solution after using numpy.linalg.solve:

print numpy.allclose(numpy.dot(a, s), b)

And I got a False (?!).

I don't know what is happening, how to find a solution, I just know that the same code runs in my Mac, but it would be very good if I could run it in other platforms. Now I'm stucked in this problem (don't have a Mac anymore) and with no clue about the cause.

The weirdest thing is that I don't receive any error on runtime warning, no feedback at all.

Thank you for any help.

EDIT:

Numpy Suit Test Results:

enter image description here

Scipy Suit Test Results:

enter image description here

20
  • 1
    Did you double check for version consistency? Perhaps something changed between the versions on your old Mac and the (presumably) newer versions on the new computer. Commented May 13, 2015 at 1:06
  • Yes, @Ajean. I also plugged a pen-drive in my Mac to get the old code and re-run it on Mac and Windows systems. It worked (Mac), but the system is too slow, so I really would like to have it running on a Windows too. This seems not to make sense at all. Commented May 13, 2015 at 1:20
  • 2
    if det(b)=0, even due to precision loss, it means your problem is not well defined. Fighting against badly conditioned matrix problem is just not the right way. Commented May 13, 2015 at 9:08
  • 1
    It rather feels like this is more due to a change in the version of numpy, scipy rather than to Mac/Windows differences. Also try running the numpy/scipy test suite both on your Mac and Windows and compare the results. The fact that the the program exists on scipy.linalg.solve looks like a segfault, make sure BLAS/LAPACK libraries are correctly installed. Commented May 13, 2015 at 11:17
  • 2
    Something else to check would be the versions of the libraries that underlie numpy. BLAS, LAPACK, and many others are installed and the builds might well be different in some way between the Windows and the Mac versions. What installation method did you use on OSX and Windows? Commented Jun 24, 2015 at 3:28

3 Answers 3

1

Download Anaconda package manager

http://continuum.io/downloads

When you download this it will already have all the dependencies for numpy worked out for you. It installs locally and will work on most platforms.

Sign up to request clarification or add additional context in comments.

Comments

0

This is not really an answer, but this blog discusses in length the problems of having a numpy ecosystem that evolves fast, at the expense of reproducibility.

By the way, which version of numpy are you using? The documentation for the latest 1.9 does not report any method called cg as the one you use...

I suggest the use of this example so that you (and others) can check the results.

>>> import numpy as np
>>> import scipy.linalg
>>> np.random.seed(123)
>>> a = np.random.random(size=(10000, 10000))
>>> b = np.random.random(size=(10000,))
>>> s_np = np.linalg.solve(a, b)
>>> s_sc = scipy.linalg.solve(a, b)
>>> np.allclose(s_np,s_sc)
>>> s_np
array([-15.59186559,   7.08345804,   4.48174646, ..., -16.43310046,
    -8.81301553, -10.77509242])

4 Comments

Hi @RamonCrehuet. I posted the versions in the comments above. They are the last ones for both Scipy and Numpy. cg comes from Scipy. docs.scipy.org/doc/scipy/reference/sparse.linalg.html
I know cg is in scipy.sparse, but you seem to be calling a numpy function. Please, clarify this.
I've edited my post to suggest a reproducible example that we can all test.
I've could'n reproduce your code here. I get memory error. However, I have 4GB of RAM when calling the solver.
0

I hope you can find the answer - one option in the future is to create a virtual machine for each of your projects, using Docker. This allows easy portability.

See a great article here discussing Docker for research.

1 Comment

Docker does not create virtual machines, it runs processes. Since the host kernel and the process kernel are shared, this almost certainly won't change any fundamental platform behavior.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.