Ginger
Ginger

Reputation: 8660

Numba Prange Example does not work

I am testing the prange example from here:

http://numba.pydata.org/numba-doc/0.11/prange.html

I have numba version 0.11.1

Unfortunately, it gives me this error:

Traceback (most recent call last):
  File "C:\Anaconda\envs\p33\lib\site-packages\IPython\core\interactiveshell.py", line 2732, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-1-d9c777b2b461>", line 1, in <module>
    execfile('C:\\Users\\Jon\\workspace\\Examples\\numba\\parallel_numba.py')
  File "C:\eclipse_kepler\plugins\org.python.pydev_2.7.5.2013052819\pysrc\_pydev_execfile.py", line 38, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc) #execute the script
  File "C:\Users\Jon\workspace\Examples\numba\parallel_numba.py", line 19, in <module>
    s0 = parallel_sum(B)
  File "numbawrapper.pyx", line 192, in numba.numbawrapper._NumbaSpecializingWrapper.__call__ (numba\numbawrapper.c:3768)
SystemError: NULL result without error in PyObject_Call

This is the code that I am using:

from numba import autojit, prange
import numpy as np

@autojit
def parallel_sum(A):
    sum = 0.0
    for i in prange(A.shape[0]):
        sum += A[i]

    return sum

B = np.array( [1,2,3] )
s0 = parallel_sum(B)

Upvotes: 2

Views: 3491

Answers (1)

JoshAdel
JoshAdel

Reputation: 68732

For some reason, if you name the numba modules, explicitly, the example works:

import numba

@numba.autojit
def parallel_sum(A):
    sum = 0.0
    for i in numba.prange(A.shape[0]):
        sum += A[i]

    return sum

Also, I'm using python 2.7 and numba 0.11.1 via conda. I got the same error with the original code.

Upvotes: 3

Related Questions