That’s a bit extreme. It is perfectly valid. In some situations, using cudaMallocHost as an alternative may be necessary (e.g. to achieve copy/compute overlap) or preferred for other reasons.
There is not enough information here to diagnose. The two variants (with new and with cudaMallocHost) should be roughly equivalent from a “legal access” perspective, so something else is going on. If you are on windows and requesting a large amount of space (which you aren’t) via cudaMallocHost, that can be an issue. Also, be sure you are actually checking those cudaStatus results. If you still need help, provide a complete example, along with the CUDA version, the GPU, and the OS you are running on.
Thanks. I just realized it was because I had a delete[] cpuAllocation I had left in there and hadn’t replaced. My mistake. I will just stick with the cudaMallocHostas it works and sounds safer going forward. Thanks.