我有一张带有CUDA的4GB和12GB gfx卡。在我的应用程序中,我使用CUDAfy.NET,在调用GPGPU.TotalMemory
属性时,它显示了一个非常大的值(绝对不正确)。与FreeMemory
相同。如何解决这个问题?
Console.WriteLine("GPU total memory: " + gpu.TotalMemory.ToString());
Console.WriteLine("GPU free memory: " + gpu.FreeMemory.ToString());
对于4GB卡,TotalMemory显示18446744072635809792字节,FreeMemory显示18446744072628600832字节。
答案 0 :(得分:0)
正如talonmies所指出的,这必然是CUDAfy中导致错误内存计算的错误,但我发现了一种不同的方法来获取信息。 CudafyByExample中的一些示例代码正在准确显示如何执行此操作!
所以,而不是阅读GPGPU类'属性gpu.TotalMemory
,我必须通过调用CudafyHost.GetDeviceProperties()
函数获取包含每个设备属性的对象列表,然后每个对象将包含我对每个CUDA图形卡所需的信息:
public static void PrintGpuProperties() // this was copied from CudafyByExample
{
int i = 0;
foreach (GPGPUProperties devicePropsContainer in CudafyHost.GetDeviceProperties(CudafyModes.Target, false))
{
Console.WriteLine(" --- General Information for device {0} ---", i);
Console.WriteLine("Name: {0}", devicePropsContainer.Name);
Console.WriteLine("Platform Name: {0}", devicePropsContainer.PlatformName);
Console.WriteLine("Device Id: {0}", devicePropsContainer.DeviceId);
Console.WriteLine("Compute capability: {0}.{1}", devicePropsContainer.Capability.Major, devicePropsContainer.Capability.Minor);
Console.WriteLine("Clock rate: {0}", devicePropsContainer.ClockRate);
Console.WriteLine("Simulated: {0}", devicePropsContainer.IsSimulated);
Console.WriteLine();
Console.WriteLine(" --- Memory Information for device {0} ---", i);
Console.WriteLine("Total global mem: {0}", devicePropsContainer.TotalMemory);
Console.WriteLine("Total constant Mem: {0}", devicePropsContainer.TotalConstantMemory);
Console.WriteLine("Max mem pitch: {0}", devicePropsContainer.MemoryPitch);
Console.WriteLine("Texture Alignment: {0}", devicePropsContainer.TextureAlignment);
Console.WriteLine();
Console.WriteLine(" --- MP Information for device {0} ---", i);
Console.WriteLine("Shared mem per mp: {0}", devicePropsContainer.SharedMemoryPerBlock);
Console.WriteLine("Registers per mp: {0}", devicePropsContainer.RegistersPerBlock);
Console.WriteLine("Threads in warp: {0}", devicePropsContainer.WarpSize);
Console.WriteLine("Max threads per block: {0}", devicePropsContainer.MaxThreadsPerBlock);
Console.WriteLine("Max thread dimensions: ({0}, {1}, {2})", devicePropsContainer.MaxThreadsSize.x, devicePropsContainer.MaxThreadsSize.y, devicePropsContainer.MaxThreadsSize.z);
Console.WriteLine("Max grid dimensions: ({0}, {1}, {2})", devicePropsContainer.MaxGridSize.x, devicePropsContainer.MaxGridSize.y, devicePropsContainer.MaxGridSize.z);
Console.WriteLine();
i++;
}
}