小编Ric*_*aña的帖子

CUDA设备中的内存分配不是预期的

我不能创建新的标签,但它应该在MANAGEDCUDA标签上,因为我使用该框架在C#中使用CUDA.

我使用此代码分配2个INT数组进行测试:

Console.WriteLine("Cells: "+sum+" Expected Total Memory (x4): "+sum*4);
int temp= 0;
temp = cntxt.GetFreeDeviceMemorySize();
Console.Write("\n Memory available before:" + cntxt.GetFreeDeviceMemorySize() + "\n");
CudaDeviceVariable<int> matrix = new CudaDeviceVariable<int>(sum);
CudaDeviceVariable<int> matrixDir = new CudaDeviceVariable<int>(sum);
Console.Write("\n Memory available after allocation:" + cntxt.GetFreeDeviceMemorySize() + "\n");
Console.WriteLine("Memory took: "+(temp - cntxt.GetFreeDeviceMemorySize()));
Console.WriteLine("Diference between the expected and allocated: " + ((temp - cntxt.GetFreeDeviceMemorySize())-sum*8));
Run Code Online (Sandbox Code Playgroud)

运行后我在控制台中得到了这个:

控制台运行

c# memory-management cuda

1
推荐指数
1
解决办法
158
查看次数

标签 统计

c# ×1

cuda ×1

memory-management ×1