Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 492760 - sci-libs/scipy memory leak
Summary: sci-libs/scipy memory leak
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Science Related Packages
URL: https://forums.gentoo.org/viewtopic-p...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-28 01:44 UTC by orionbelt2
Modified: 2013-12-02 07:06 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description orionbelt2 2013-11-28 01:44:18 UTC
There is a pretty serious memory leak in sci-libs/scipy's griddata module. I reported it to SciPy's bug tracker but they claim it is a problem with the Gentoo build. Here is the bug report and the suggested fix:

https://github.com/scipy/scipy/issues/2388

http://stackoverflow.com/questions/17438239/memory-leak-in-scipy-griddata-ver-0-12-0

If i understand this correctly, some SciPy code must be recompiled with a bug-corrected version of cython to fix the problem...

I can reproduce the memory leak with both stable and masked versions of cython and scipy, i.e. (sci-libs/scipy-0.12.1 & dev-python/cython-0.19.1) and (sci-libs/scipy-0.13.0 & dev-python/cython-0.19.2), where i was sure to build cython first and scipy afterwards to make sure that the latest cython would be used (if needed) to compile scipy...

I don't know whether it's useful, but the memory leak happens only for 'linear' and 'cubic' griddata methods, not for 'nearest'.

Thanks!

PS  Transfered here from the forum thread: https://forums.gentoo.org/viewtopic-p-7449808.html
Comment 1 Hypnos 2013-11-28 03:03:32 UTC
Can you track down the patch to cpython that fixes this issue?  Then we can see if the fix is already in cpython-0.19.x or it needs to be applied by the ebuild.
Comment 2 orionbelt2 2013-11-28 11:14:50 UTC
According to the stackoverflow.com link in my first comment above, cython 0.19.2 should work:

http://stackoverflow.com/a/19362976

"First updating cython to the most recent version 0.19.2, then recompiling scipy from sources (but the ones from github, not from .tar.gz)"

Cython 0.19.2 did not work for me. The stackoverflow comment was made on October 14 when the latest scipy version on sourceforge was 0.13.0. Gentoo's latest masked scipy is still 0.13.0, and as far as i can tell it uses the tarball. As i said in my first comment, it did not work.

So my suggestion would be to bump scipy to 0.13.1, the latest version on sourceforge. I suspect that *that* tarball incorporates the github fix, and therefore should resolve the bug.
Comment 3 Justin Lecher (RETIRED) gentoo-dev 2013-11-28 12:05:56 UTC
Please try scipy-0.13.1.
Comment 4 orionbelt2 2013-11-28 17:12:39 UTC
Justin,

OK, so i did the following:

1. I unmasked dev-python/cython and dev-python/numpy and updated my Gentoo. Now i am on dev-python/cython-0.19.2, dev-python/numpy-1.8.0, and dev-lang/python-2.7.5-r3.

2. I downloaded the SciPy 0.13.1 tarball from http://sourceforge.net/projects/scipy/files/scipy/

3. I installed SciPy 0.13.1 in a local directory via "python setup.py install --prefix=$HOME/foo/"

4. I ran the problematic python script mentioned in http://stackoverflow.com/questions/17438239/memory-leak-in-scipy-griddata-ver-0-12-0 as well as my own script that led me to notice the problem in the first place. I included a "print scipy.interpolate.__file__ " statement to make sure that the updated SciPy was being used.

Result: Unfortunately, in both cases the memory leak persists.
Comment 5 Justin Lecher (RETIRED) gentoo-dev 2013-11-29 06:48:55 UTC
(In reply to orionbelt2 from comment #4)
> Justin,
> 
> OK, so i did the following:
> 
> 1. I unmasked dev-python/cython and dev-python/numpy and updated my Gentoo.
> Now i am on dev-python/cython-0.19.2, dev-python/numpy-1.8.0, and
> dev-lang/python-2.7.5-r3.
> 
> 2. I downloaded the SciPy 0.13.1 tarball from
> http://sourceforge.net/projects/scipy/files/scipy/

I bumped it in the tree so you can use it there. 

I will look into that tonight.
Comment 6 orionbelt2 2013-11-29 14:26:10 UTC
I emerged scipy-0.13.1 and tried again the tests with this configuration:

sci-libs/scipy-0.13.1
dev-python/numpy-1.8.0
dev-lang/python-2.7.5-r3

The memory leak is always present.
Comment 7 Justin Lecher (RETIRED) gentoo-dev 2013-11-29 14:28:51 UTC
same here. I will contact upstream.
Comment 8 orionbelt2 2013-11-29 14:31:48 UTC
Thanks.

A reminder that i had already contacted SciPy before bothering Gentoo:

https://github.com/scipy/scipy/issues/2388

Just in case you want to follow up on that thread.
Comment 9 Justin Lecher (RETIRED) gentoo-dev 2013-11-29 16:05:47 UTC
+*scipy-0.13.1-r1 (29 Nov 2013)
+
+  29 Nov 2013; Justin Lecher <jlec@gentoo.org> -scipy-0.13.1.ebuild,
+  +scipy-0.13.1-r1.ebuild:
+  Force rebuild of .c files to fix memory leak, #492760
+
Comment 10 orionbelt2 2013-11-29 16:19:42 UTC
I just ran "eix-sync" and 0.13.1-r1 is not yet available. Is this just a question of propagating the change to the mirrors? Any idea how long it takes for this to happen? Just to avoid abusing the repositories with repeated attempts... :)
Comment 11 Justin Lecher (RETIRED) gentoo-dev 2013-11-29 16:22:38 UTC
(In reply to orionbelt2 from comment #10)
> I just ran "eix-sync" and 0.13.1-r1 is not yet available. Is this just a
> question of propagating the change to the mirrors? Any idea how long it
> takes for this to happen? Just to avoid abusing the repositories with
> repeated attempts... :)

takes around  1 hour.

if you want to have it faster, edit the ebuild like this

python_compile() {
    ${EPYTHON} tools/cythonize.py || die
    distutils-r1_python_compile ${SCIPY_FCONFIG}
}


and run

repoman fix

then you can emerge scipy again.
Comment 12 orionbelt2 2013-11-30 02:04:05 UTC
Justin,

Have you tried scipy-0.13.1-r1 and confirmed that it works?

Unfortunately, it still does not work for me. Again, for reference, i am using:

sci-libs/scipy-0.13.1-r1
dev-python/numpy-1.8.0
dev-python/cython-0.19.2
dev-lang/python-2.7.5-r3

Could someone else please give it a try?
Comment 13 Justin Lecher (RETIRED) gentoo-dev 2013-11-30 08:50:42 UTC
(In reply to orionbelt2 from comment #12)
> Justin,
> 
> Have you tried scipy-0.13.1-r1 and confirmed that it works?
> 
> Unfortunately, it still does not work for me. Again, for reference, i am
> using:
> 
> sci-libs/scipy-0.13.1-r1
> dev-python/numpy-1.8.0
> dev-python/cython-0.19.2
> dev-lang/python-2.7.5-r3
> 
> Could someone else please give it a try?

That should work. Please attach a build.log.
Comment 14 Justin Lecher (RETIRED) gentoo-dev 2013-12-01 17:00:37 UTC
+*scipy-0.13.1-r2 (01 Dec 2013)
+
+  01 Dec 2013; Justin Lecher <jlec@gentoo.org> -scipy-0.13.1-r1.ebuild,
+  +scipy-0.13.1-r2.ebuild:
+  Make realy sure cython is run always, #492760
+

r2 is really fixed now.
Comment 15 orionbelt2 2013-12-02 03:50:39 UTC
I can confirm that i see no memory leak with scipy-0.13.1-r2 (there was still with r1). Thanks for taking care of this!

I will now have to remember to remove cython, numpy, scipy and tempita from my package.keywords when scipy-0.13.1-r2 becomes stable...
Comment 16 Justin Lecher (RETIRED) gentoo-dev 2013-12-02 07:06:23 UTC
(In reply to orionbelt2 from comment #15)
> I can confirm that i see no memory leak with scipy-0.13.1-r2 (there was
> still with r1). Thanks for taking care of this!
> 
> I will now have to remember to remove cython, numpy, scipy and tempita from
> my package.keywords when scipy-0.13.1-r2 becomes stable...

my idea it  to wait for 0.13.2 and give that a quick stabilization.