Run Python with CUDA on Jetson TX2

Hello everyone,
I’m trying to test the difference in execution time between a normal python program and the same program with CUDA. The Programm is described as followed

import numpy as np
from timeit import default_timer as timer
from numba import vectorize

@vectorize(['float32(float32)'], target='cuda')
def func(a):                                 
    for i in range(10000000): 
        a[i]+= 1 
def func2(a): 
    for i in range(10000000): 
        a[i]+= 1
if __name__=="__main__": 
    n = 10000000                            
    a = np.ones(n, dtype = np.float64) 
    b = np.ones(n, dtype = np.float32) 
      
    start = timer() 
    func(a) 
    print("without GPU:", timer()-start)     
      
    start = timer() 
    func2(a) 
    print("with GPU:", timer()-start)

func(a) is normal python function and func2(a) with cuda. when i run the program i get the following error:

Traceback (most recent call last):
File “gpu3.py”, line 5, in
@vectorize([‘float32(float32)’], target=‘cuda’)
File “/usr/local/lib/python3.6/dist-packages/numba/npyufunc/decorators.py”, line 120, in wrap
vec.add(sig)
File “/usr/local/lib/python3.6/dist-packages/numba/npyufunc/deviceufunc.py”, line 403, in add
corefn, return_type = self._compile_core(devfnsig)
File “/usr/local/lib/python3.6/dist-packages/numba/cuda/vectorizers.py”, line 17, in _compile_core
cudevfn = cuda.jit(sig, device=True, inline=True)(self.pyfunc)
File “/usr/local/lib/python3.6/dist-packages/numba/cuda/decorators.py”, line 107, in device_jit
debug=debug)
File “/usr/local/lib/python3.6/dist-packages/numba/cuda/compiler.py”, line 189, in compile_device
return DeviceFunction(pyfunc, return_type, args, inline=True, debug=False)
File “/usr/local/lib/python3.6/dist-packages/numba/cuda/compiler.py”, line 220, in init
debug=self.debug, inline=self.inline)
File “/usr/local/lib/python3.6/dist-packages/numba/compiler_lock.py”, line 32, in _acquire_compile_lock
return func(*args, **kwargs)
File “/usr/local/lib/python3.6/dist-packages/numba/cuda/compiler.py”, line 50, in compile_cuda
locals={})
File “/usr/local/lib/python3.6/dist-packages/numba/compiler.py”, line 551, in compile_extra
return pipeline.compile_extra(func)
File “/usr/local/lib/python3.6/dist-packages/numba/compiler.py”, line 331, in compile_extra
return self._compile_bytecode()
File “/usr/local/lib/python3.6/dist-packages/numba/compiler.py”, line 393, in _compile_bytecode
return self._compile_core()
File “/usr/local/lib/python3.6/dist-packages/numba/compiler.py”, line 373, in _compile_core
raise e
File “/usr/local/lib/python3.6/dist-packages/numba/compiler.py”, line 364, in _compile_core
pm.run(self.state)
File “/usr/local/lib/python3.6/dist-packages/numba/compiler_machinery.py”, line 347, in run
raise patched_exception
File “/usr/local/lib/python3.6/dist-packages/numba/compiler_machinery.py”, line 338, in run
self._runPass(idx, pass_inst, state)
File “/usr/local/lib/python3.6/dist-packages/numba/compiler_lock.py”, line 32, in _acquire_compile_lock
return func(*args, **kwargs)
File “/usr/local/lib/python3.6/dist-packages/numba/compiler_machinery.py”, line 302, in _runPass
mutated |= check(pss.run_pass, internal_state)
File “/usr/local/lib/python3.6/dist-packages/numba/compiler_machinery.py”, line 275, in check
mangled = func(compiler_state)
File “/usr/local/lib/python3.6/dist-packages/numba/typed_passes.py”, line 95, in run_pass
raise_errors=self._raise_errors)
File “/usr/local/lib/python3.6/dist-packages/numba/typed_passes.py”, line 67, in type_inference_stage
infer.propagate(raise_errors=raise_errors)
File “/usr/local/lib/python3.6/dist-packages/numba/typeinfer.py”, line 985, in propagate
raise errors[0]
numba.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Invalid use of Function() with argument(s) of type(s): (float32, int64)

  • parameterized
    In definition 0:
    All templates rejected with literals.
    In definition 1:
    All templates rejected without literals.
    In definition 2:
    All templates rejected with literals.
    In definition 3:
    All templates rejected without literals.
    In definition 4:
    All templates rejected with literals.
    In definition 5:
    All templates rejected without literals.
    In definition 6:
    All templates rejected with literals.
    In definition 7:
    All templates rejected without literals.
    In definition 8:
    All templates rejected with literals.
    In definition 9:
    All templates rejected without literals.
    In definition 10:
    All templates rejected with literals.
    In definition 11:
    All templates rejected without literals.
    In definition 12:
    All templates rejected with literals.
    In definition 13:
    All templates rejected without literals.
    This error is usually caused by passing an argument of a type that is unsupported by the named function.
    [1] During: typing of intrinsic-call at gpu3.py (8)

File “gpu3.py”, line 8:
def func(a):

for i in range(10000000):
a[i]+= 1
^

Does anyone have an ide what could be the reason for that?

thanks in Advance
Khaled

Hi,

Is this issue duplicate to topic 1069404?
https://devtalk.nvidia.com/default/topic/1069404/jetson-tx2/testing-the-excecution-with-and-with-out-gpu-and-cuda-in-jetson-tx2/

If yes, would can check the following status on the original topic directly.
Thanks.