weave and 64 bit issues

Jadhav, Alok alok.jadhav at credit-suisse.com
Tue May 14 02:54:25 EDT 2013


Hi everyone,

 

I am facing a strange problem using weave on 64 bit machine.
Specifically with weave's inline function. It has something to do with
weave's catalog. 

 

Similar issues I found in the past (very old)

 

http://mail.scipy.org/pipermail/scipy-dev/2006-June/005908.html

http://mail.scipy.org/pipermail/scipy-dev/2005-June/003042.html

 

 

I have a simple script to calculate moving average using weave's inline
function. 

 

 

 

File mvg.py

 

import numpy as np

import scipy.weave as weave

import distutils.sysconfig

import distutils.dir_util

import os

 

distutils.sysconfig._config_vars["LDSHARED"]="-LC:\strawberry64\c\x86_64
-w64-mingw32\lib"

 

 

def ExpMovAvg(data,time,lag):

    if (data.size!=time.size):

        print "error in EMA, data and time have different size"

        return None

    result=np.repeat(0.0,data.size)

    code="""

    #line 66 "basics.py"

    result(0)=data(0);

    for (int i=0;i<data.size()-1;i++)

    {

        //double alpha=1-(2.0/(lag+1)*(time(i)-time(i-1)));

        double dt=time(i+1)-time(i);

        double alpha=pow(0.13533, dt / lag);

        if(alpha>1)

        {

            alpha=10;

        }

        result(i+1)=(1-alpha)*data(i)+alpha*result(i);

    }

    """

 
weave.inline(code,["data","time","lag","result"],type_converters=weave.c
onverters.blitz,headers=["<math.h>"],compiler="gcc",verbose=2)

    return result

 

 

file test.py

 

import string

import numpy as np

import mvg

 

print(mvg.ExpMovAvg(np.array(range(10)),np.array(range(10)),2))

 

 

 

Output:

 

 

Working output:

 

Y:\STMM\alpha\klse\PROD>c:\python27\python.exe
s:\common\tools\python\python-2.7-64bit\test.py

[ 0.          0.          0.63212774  1.49679774  2.44701359  3.42869938
4.42196209  5.41948363  6.41857187  7.41823646]

 

Now if I keep running the script multiple times, sometimes I see correct
output... but suddenly sometimes I get below error.

 

Y:\STMM\alpha\klse\PROD>c:\python27\python.exe
s:\common\tools\python\python-2.7-64bit\test.py

repairing catalog by removing key

<weave: compiling>

Looking for python27.dll

running build_ext

running build_src

build_src

building extension "sc_44f3fe3c65d5c3feecb45d9269ac207f5" sources

build_src: building npy-pkg config files

Looking for python27.dll

customize Mingw32CCompiler

customize Mingw32CCompiler using build_ext

Looking for python27.dll

customize Mingw32CCompiler

customize Mingw32CCompiler using build_ext

building 'sc_44f3fe3c65d5c3feecb45d9269ac207f5' extension

compiling C++ sources

C compiler: g++ -g -DDEBUG -DMS_WIN64 -O0 -Wall

 

compile options: '-Ic:\python27\lib\site-packages\scipy\weave
-Ic:\python27\lib\site-packages\scipy\weave\scxx
-Ic:\python27\lib\site-packages\scipy\weave\blitz

-Ic:\python27\lib\site-packages\numpy\core\include -Ic:\python27\include
-Ic:\python27\PC -c' 

 g++ -g -DDEBUG -DMS_WIN64 -O0 -Wall
-Ic:\python27\lib\site-packages\scipy\weave

-Ic:\python27\lib\site-packages\scipy\weave\scxx
-Ic:\python27\lib\site-packages\scipy\weave\blitz
-Ic:\python27\lib\site-packages\numpy\core\include -Ic:\pytho

n27\include -Ic:\python27\PC -c
c:\users\ajadhav2\appdata\local\temp\ajadhav2\python27_compiled\sc_44f3f
e3c65d5c3feecb45d9269ac207f5.cpp -o c:\users\ajadhav2\ap

pdata\local\temp\ajadhav2\python27_intermediate\compiler_2d3e1e2e4de6a91
419d2376b162e5342\Release\users\ajadhav2\appdata\local\temp\ajadhav2\pyt
hon27_compiled\s

c_44f3fe3c65d5c3feecb45d9269ac207f5.o

Found executable C:\strawberry\c\bin\g++.exe

g++ -g -DDEBUG -DMS_WIN64 -O0 -Wall
-Ic:\python27\lib\site-packages\scipy\weave-Ic:\python27\lib\site-packag
es\scipy\weave\scxx -Ic:\python27\lib\site-packages

\scipy\weave\blitz -Ic:\python27\lib\site-packages\numpy\core\include
-Ic:\python27\include -Ic:\python27\PC -c
c:\python27\lib\site-packages\scipy\weave\scxx\w

eave_imp.cpp -o
c:\users\ajadhav2\appdata\local\temp\ajadhav2\python27_intermediate\comp
iler_2d3e1e2e4de6a91419d2376b162e5342\Release\python27\lib\site-packages

\scipy\weave\scxx\weave_imp.o

g++ -g -shared
c:\users\ajadhav2\appdata\local\temp\ajadhav2\python27_intermediate\comp
iler_2d3e1e2e4de6a91419d2376b162e5342\Release\users\ajadhav2\appdata\loc
a

l\temp\ajadhav2\python27_compiled\sc_44f3fe3c65d5c3feecb45d9269ac207f5.o
c:\users\ajadhav2\appdata\local\temp\ajadhav2\python27_intermediate\comp
iler_2d3e1e2e4d

e6a91419d2376b162e5342\Release\python27\lib\site-packages\scipy\weave\sc
xx\weave_imp.o -Lc:\python27\libs -Lc:\python27\PCbuild\amd64 -lpython27
-lmsvcr90 -o c:

\users\ajadhav2\appdata\local\temp\ajadhav2\python27_compiled\sc_44f3fe3
c65d5c3feecb45d9269ac207f5.pyd

running scons

Traceback (most recent call last):

  File "s:\common\tools\python\python-2.7-64bit\test.py", line 5, in
<module>

    print(mvg.ExpMovAvg(np.array(range(10)),np.array(range(10)),2))

  File "s:\common\tools\python\python-2.7-64bit\mvg.py", line 30, in
ExpMovAvg

 
weave.inline(code,["data","time","lag","result"],type_converters=weave.c
onve

rters.blitz,headers=["<math.h>"],compiler="gcc",verbose=2)

  File "c:\python27\lib\site-packages\scipy\weave\inline_tools.py", line
355, in

inline

    **kw)

  File "c:\python27\lib\site-packages\scipy\weave\inline_tools.py", line
488, in

compile_function

    exec 'import ' + module_name

  File "<string>", line 1, in <module>

ImportError: DLL load failed: Invalid access to memory location.

 

Y:\STMM\alpha\klse\PROD>

 

 

 

For everytime there is an error I have one observation, the message has
notification

 

"repairing catalog by removing key"  which leads to DLL load failed
error.

 

 

Any ideas?

 

-

Alok 

 

 

 


=============================================================================== 
Please access the attached hyperlink for an important electronic communications disclaimer: 
http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html 
=============================================================================== 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130514/04079299/attachment.html>


More information about the Python-list mailing list