I am working on a CUDA project that uses streams, this project is part of a wide, complex solution. I noticed processing time spikes in the CUDA parts execution time, as a sum of Asynchronous copy to the memory, kernels launched, and results copied back.
- Initially I was creating and destroying streams (cudaStreamDestroy) at each cycle, but I had to remove that and reuse streams, as that was creating processing time spikes that that doubled in duration at each iteration of continuous running time (e.g. 15ms at 10mins, 30ms at 20mins), of the magnitude of up to a few seconds.
- I noticed using Nsight System they tend to happen as I call cudaMemcpyAsync, so with more streams the possibility to get a spike increases. I wasn’t able to reproduce spikes while using Nsight Compute due to it slowing the processor down and the reduced number of cycles.
- The spikes are somehow linked to the number of streams I launch, and the other processes on the CPU and integrated graphic card. Their magnitude is linked to the average processing time.
- Increasing the number of streams has a higher impact on speed than increasing the amount of data processed in each stream.
- I mitigated most of the spikes by reducing the load on the CPU and GPU, but I am left now with a spike of 25ms (usual process time is 2 ms up to 10 ms as I increase the number of streams), when I also have an InfluxDB query happening at the same time, that moves data between buckets. Writing to the database is not an issue, only moving the data between buckets is.
My questions are,
- What is the reason and how can I reduce the impact of InfluxDB queries, and other processes on my CUDA project?
- Is there something better I can do with my streams, still maintaining them fully asynchronous?
This is my first experience with CUDA so I am interested to understand if there is a better approach for using streams, and what sort of CPU processes are known to have a negative effect on my CUDA process.
I am using Cuda Toolkit 12.8, Studio Driver 576.52. Only my solution and Unity running on Nvidia card.
Many thanks.