0

CUDA 设备上有大量数据等待机器学习算法进行处理。但是我对设备的内存有些担心,因此我尝试使用浮点数而不是双精度数(我想这是一个很好的解决方案,除非有人指出更好)。有没有办法为从浮点数获得的结果保持双精度?我猜不是。即使这是一个有点愚蠢的问题。那么在设备上处理大量数据实例的另一种正确方法是什么。

4

2 回答 2

2

不,double如果您将数据处理为float. 将其作为double. 如果内存大小是个问题,通常的方法是分块处理数据。将一个块复制到 GPU,启动 GPU 处理,在处理过程中,将更多数据复制到 GPU,并将一些结果复制回来。这是处理“不适合”GPU 内存大小的问题的标准方法。

这称为复制和计算的重叠,您使用 CUDA 流来完成此操作。CUDA 示例(例如简单的多副本和计算)有各种代码来演示如何使用流。

于 2013-06-21T13:18:59.877 回答
1

You can indeed compute double precision results from floating point data. At any point in your calculation you can cast a float value to a double value, and according to standard C type promotion rules from there on all calculations with this value will be in double precision.

This applies as long as you use double precision variables to store the result and don't cast it to any other type. Beware of implicit casts in function calls.

于 2013-06-21T13:43:10.080 回答