首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >GPGPU.TotalMemory显示出极其巨大的价值

GPGPU.TotalMemory显示出极其巨大的价值
EN

Stack Overflow用户
提问于 2015-07-22 08:09:02
回答 1查看 225关注 0票数 2

我有一个4GB和12 4GB的gfx卡与数据自动化系统。在我的应用程序中,我使用CUDAfy.NET,当调用GPGPU.TotalMemory属性时,它显示了一个非常巨大的值(绝对不正确)。FreeMemory也是如此。怎么解决这个问题?

代码语言:javascript
复制
Console.WriteLine("GPU total memory: " + gpu.TotalMemory.ToString());
Console.WriteLine("GPU free memory: " + gpu.FreeMemory.ToString());

对于4GB卡,TotalMemory显示18446744072635809792字节,FreeMemory显示18446744072628600832字节。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-11-02 08:29:56

正如talonmies所指出的,这一定是CUDAfy中的一个错误,它会导致不正确的内存计算,但我找到了另一种获取信息的方法。CudafyByExample中的一些示例代码显示了如何做到这一点!因此,不必读取GPGPU类的属性gpu.TotalMemory,我必须通过调用CudafyHost.GetDeviceProperties()函数获得包含每个设备属性的对象列表,然后每个对象将包含我想要的每个CUDA显卡的信息:

代码语言:javascript
复制
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++;
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31557406

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档