cuda.mem_alloc没有分配内存

时间:2018-05-30 06:45:21

标签: cuda pycuda

在第一次调用时,cuda.mem_alloc在GPU中分配了内存,但在第二次调用中,cuda.mem_alloc没有分配,如下所示。这两个电话来自jupyter笔记本中的同一个单元格,任何人都可以解释其背后的原因吗?

import numpy as np
#PyCUDA imports
import pycuda.driver as cuda
import pycuda.autoinit
#####################first call###############
print(cuda.mem_get_info()) #(16608854016, 17062100992)

distances = np.zeros(shape = 6, dtype = np.float32)
distances_gpu = cuda.mem_alloc(distances.nbytes)
print(cuda.mem_get_info()) #(16606756864, 17062100992)

#####################second call###############
print(cuda.mem_get_info()) #(16606756864, 17062100992)
d = np.zeros(shape = 6, dtype = np.float32)
d1 = cuda.mem_alloc(d.nbytes)
print(cuda.mem_get_info()) #(16606756864, 17062100992)

0 个答案:

没有答案