Hi,
I’m having a problem with migrating code that runs on a PC to the Jetson AGX Xavier ( running Tegra Linux ).
The software crashes ( seg fault ) when I run it on the Xavier, but it works on the PC.
I have tried to run the code in gdb and it turns out that it crashes the doing a memcpy.
memcpy(&buffer_[extra_buffer_index_], sample.data_.data(), sample.data_.size() * sizeof(int16_t));`
The buffer is allocated like this:
cudaMallocManaged(reinterpret_cast<void**>(&buffer_), full_buffer_size_ * sizeof(int16_t));
So I’ve guessed that changeing the memcpy call to:
cudaMemcpy(&buffer_[extra_buffer_index_], sample.data_.data(), sample.data_.size() * sizeof(int16_t), cudaMemcpyDefault);
Now the code does not crash during the copying any more, however it crashes on other places in the code. The place in the code where the crash occurs is not always the same, but I have a feeling that it is related to reading/writing std::vector’s.
I have some questions regarding this that I was hoping that someone in this forum could help me with:
- I have suspicion that this problem is related to the Unified Memory on the Xavier, and does changing memcpy with cudaMemcpy fix this, and why did it work on the PC?
- Is it problematic to use std::vector on units with unified memory?
- Is there a way to disable the unified memory and have separate memories for GPU and CPU, so that the system would behave as on the PC?
- Does someone have some tips regarding debugging issues like this?
All help is highly appreciated, thanks!