Skip to content

Pulling to Host Python #7

Description

@JT17

I'm trying to convert from a tensor to a numpy array, but whenever I do, I get an error

python: /home/mobile/Downloads/CUV/src/cuv/basics/tensor.hpp:1138: bool cuv::tensor<V, M, L>::copy_memory(const cuv::tensor<V, _M, _L>&, bool, cudaStream_t) [with OM = cuv::dev_memory_space; OL = cuv::row_major; V = float; M = cuv::host_memory_space; L = cuv::row_major; cudaStream_t = CUstream_st*]: Assertion `m_memory.get()' failed.
Aborted (core dumped)

Even when it is quite simple such as the example1.py:

import cuv_python as cp
import numpy as np

h = np.zeros((1,256)) # create numpy matrix
d = cp.dev_tensor_float(h) # constructs by copying numpy_array

h2 = np.zeros((1,256)).copy("F") # create numpy matrix
d2 = cp.dev_tensor_float_cm(h2) # creates dev_tensor_float_cm (column-major float) object

cp.fill(d,1) # terse form
cp.apply_nullary_functor(d,cp.nullary_functor.FILL,1) # verbose form

h=d.np # pull and convert to numpy
print type(h)
assert(np.sum(h) == 256)
assert(cp.sum(d) == 256)
d.dealloc() # explicitly deallocate memory (optional)

I don't have any problems with the C++ examples but whenever a program runs into something such as h=d.np I get that assertion failed error. Any ideas?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions