正如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++;
}
}
来源
2015-11-02 08:29:56
Val
这看起来像某种32位整数溢出错误。你可能应该联系开发者让他们知道这个。 – talonmies
18446744072635809792是'FFFFFFFFC0000000'和18446744072628600832是'FFFFFFFFBF920000',它们看起来像是上半部分的64位整数,表明在@talonmies暗示的地方存在一个错误。丢弃上半部分会导致大约3 GB的结果。 –
好吧,我用http://stackoverflow.com/questions/341243/how-can-i-find-the-amount-of-video-ram-installed-through-a-wmi-call(但显然不得不使用'ulong'变量而不是'int'),它现在显示正确的内存大小。但是我仍然会尝试使用适当的CUDAfy函数。 – Val