python-3.xchainercupy

TypeError: Argument 'x' has incorrect type (expected cupy.core.core.ndarray, got numpy.ndarray)


Executing the following minimal example in cupy.

import numpy, cupy, cupyx

print( cupyx.get_runtime_info() )

mydata = numpy.empty((3,), dtype='f')

#gpu = False
gpu = True
if not gpu:
    xp = numpy
else:
    xp = cupy

    mydata_like = xp.zeros_like(mydata)

in the following manner

(venv) user@ailx216:/work/sandbox$ CUDA_PATH=/usr/local/cuda-9.1 python cupy_test.py

Gives me this error:

  File "chainer_test.py", line 14, in <module>
    mydata_like = xp.zeros_like(mydata)
/cupy/creation/basic.py", line 205, in zeros_like
    order, strides, memptr = _new_like_order_and_strides(a, dtype, order)
/cupy/creation/basic.py", line 35, in _new_like_order_and_strides
    order = chr(_update_order_char(a, ord(order)))
TypeError: Argument 'x' has incorrect type (expected cupy.core.core.ndarray, got numpy.ndarray)

The output of print( cupyx.get_runtime_info() ) is as below:

CuPy Version          : 6.2.0
CUDA Root             : /usr/local/cuda-9.1/
CUDA Build Version    : 9010
CUDA Driver Version   : 10000
CUDA Runtime Version  : 9010
cuDNN Build Version   : 7102
cuDNN Version         : 7102
NCCL Build Version    : 2115
NCCL Runtime Version  : (unknown)

How can I debug this ?


Solution

  • My original posting had a silly error. Here is a minimal cupy test that works for me. Thanks for your help.

    import numpy, cupy, cupyx
    
    print( cupyx.get_runtime_info() )
    
    
    gpu = True
    if not gpu:
        xp = numpy
    else:
        xp = cupy
    
    mydata = xp.empty((3,), dtype='f')    
    mydata_like = xp.zeros_like(mydata)