简体   繁体   English

将原始数据从内存复制到文件(cuda)

[英]Copy raw data from the memory to a file (cuda)

For debugging purposes I want to copy the raw data that I have in my cuda memory to a file and make it possible to read it again later on and send it back to the memory. 出于调试目的,我想将我在cuda内存中的原始数据复制到文件中,以便稍后再次读取它并将其发送回内存。

What's the best way to dump this to a file. 将此转储到文件的最佳方法是什么? The type of the variable that is in there can change. 其中变量的类型可以更改。

There's really no direct way to go from cuda device memory to a file. 从cuda设备内存到文件真的没有直接的方法。

So you'll need to copy the data back to the host first. 因此,您需要先将数据复制回主机。 For whatever data is on your device, create the same kind of data (pointer, and allocation) on the host. 对于设备上的任何数据,请在主机上创建相同类型的数据(指针和分配)。 Then do a cudaMemcpy operation specifying cudaMemcpyDeviceToHost . 然后执行cudaMemcpy 操作,指定cudaMemcpyDeviceToHost

Then use whatever you think is the best method to dump host memory to a file. 然后使用您认为是将主机内存转储到文件的最佳方法。 There's nothing CUDA-specific about that. 关于这一点没有CUDA特定的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM