New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Argument has invalid type for CuPy array #2786

stsievert opened this Issue Mar 4, 2018 · 1 comment


None yet
2 participants
Copy link

stsievert commented Mar 4, 2018

It looks like types in CuPy aren't recognized or supported. That is, when I vectorize a function with float64, I get an error message "argument has invalid type".

CuPy is effectively NumPy for the GPU. They claim to be a drop in replacement for NumPy, and have support for ufuncs, though they have some minor differences from NumPy.

Here's the script I ran:

from numba import vectorize, float64
import numpy as np
import cupy

@vectorize([float64(float64, float64)], target='cuda')
def add(x, y):
    return x + y

if __name__ == "__main__":
    n = 10
    x = cupy.random.rand(n).astype('float64')
    y = cupy.random.rand(n).astype('float64')

    #  tested this input too; add worked
    #  x = np.random.rand(n).astype('float64')
    #  y = np.random.rand(n).astype('float64')

    add(x, y)

Here's the traceback the script produced:

(chainer_p36) ubuntu@ip-172-31-41-118:~$ python
Traceback (most recent call last):
  File "", line 12, in <module>
    add_numba_cupy(x2, y2)
  File "/home/ubuntu/anaconda3/envs/chainer_p36/lib/python3.6/site-packages/numba/cuda/", line 88, in __call__
    return, args, kws)
  File "/home/ubuntu/anaconda3/envs/chainer_p36/lib/python3.6/site-packages/numba/npyufunc/", line 248, in call
    args = cr.get_arguments()
  File "/home/ubuntu/anaconda3/envs/chainer_p36/lib/python3.6/site-packages/numba/npyufunc/", line 204, in get_arguments
  File "/home/ubuntu/anaconda3/envs/chainer_p36/lib/python3.6/site-packages/numba/npyufunc/", line 105, in _fill_arrays
    raise TypeError("argument #%d has invalid type" % (i + 1,))
TypeError: argument #1 has invalid type

Environment details:

  • Amazon EC2 p2.xlarge, instance of Ubuntu Deep Learning 5.0 AMI
  • numba version: 0.37.0
  • CuPy version: 2.4.0

@stsievert stsievert changed the title Types not recognized/supported for CuPy Argument has invalid type for CuPy array Mar 10, 2018


This comment has been minimized.

Copy link

seibert commented Aug 27, 2018

Note that with CuPy 5.0.0b4 (due to this PR: cupy/cupy#1144), Numba will recognize CuPy arrays as GPU device arrays automatically.

@seibert seibert closed this Aug 27, 2018

@seibert seibert added this to Done in Minor Features Aug 27, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment