GPGPU.TotalMemory显示出极其巨大的价值
GPGPU.TotalMemory shows extremely huge value
我有一张带有 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字节。
正如 talonmies 所指出的,这一定是 CUDAfy 中的一个错误,导致内存计算不正确,但我找到了另一种获取信息的方法。 CudafyByExample 中的一些示例代码准确地展示了如何做到这一点!
因此,不是读取 GPGPU class' 属性 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++;
}
}
我有一张带有 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字节。
正如 talonmies 所指出的,这一定是 CUDAfy 中的一个错误,导致内存计算不正确,但我找到了另一种获取信息的方法。 CudafyByExample 中的一些示例代码准确地展示了如何做到这一点!
因此,不是读取 GPGPU class' 属性 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++;
}
}