python - pyCUDA can't print result -


recently, use pip install pycuda python3.4.3. found when test sample code(https://documen.tician.de/pycuda/tutorial.html#getting-started), can't print result without error message,the program can end. can't understand what's wrong code or python,thank answer.this code:

import pycuda.driver cuda import pycuda.autoinit pycuda.compiler import sourcemodule import numpy import random =[random.randint(0,20) in range(20)] = a.astype(numpy.float32) a_gpu = cuda.mem_alloc(a.nbytes) cuda.memcpy_htod(a_gpu, a) mod = sourcemodule("""   __global__ void doublify(float *a)   {     int idx = threadidx.x + threadidx.y*4;     a[idx] *= 2;   }   """) func = mod.get_function("doublify") func(a_gpu, block=(4,4,1)) a_doubled = numpy.empty_like(a) cuda.memcpy_dtoh(a_doubled, a_gpu) print(a_doubled) print(a) 


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -