Start using pycuda quastions

Hello.
I started to learn pycuda for my project. I started with small tutorial I found. So I tested it with cpu and cuda and got strange results, cpu was 50 times faster. Please advice. Here is code:

start_time = time.time()
for i in range (100000):
    a_gpu = gpuarray.to_gpu(numpy.random.randn(4,4).astype(numpy.float32))
end_time = time.time()  # end time
elapsed_time = end_time - start_time
print(f"{elapsed_time:.2f} seconds")
print(a_gpu)

0.20 seconds with cpu and 10.14 seconds with cuda

Your code creates a small numpy array of random values, and transfers it to the GPU (repeatedly). No computation or other work of any kind is being done on the GPU.

This doesn’t look like a sensible test to me. Many trivially small codes will not show interesting performance on the GPU compared to the CPU.