Disabling OpenGL Causes Crash for the Particles Example

I am trying to modify the 5_Simulation/particles example so that it runs in headless mode.

I took out calls from OpenGL, I make them manually in a loop, I set
bUseOpenGL to false everywhere,

In particles.cpp

int
main(int argc, char **argv)
{
    numParticles = NUM_PARTICLES;
    uint gridDim = GRID_SIZE;

    gridSize.x = gridSize.y = gridSize.z = gridDim;
    printf("grid: %d x %d x %d = %d cells\n", gridSize.x, gridSize.y, gridSize.z, gridSize.x*gridSize.y*gridSize.z);
    printf("particles: %d\n", numParticles);

    //initGL(&argc, argv);

    cudaInit(argc, argv);

    initParticleSystem(numParticles, gridSize, false);

    initParams();

    for (int i=0;i<1000;i++){
	display();
    }

    exit(0);
}
...
...
void display()
{
    psystem->setIterations(iterations);
    psystem->setDamping(damping);
    psystem->setGravity(-gravity);
    psystem->setCollideSpring(collideSpring);
    psystem->setCollideDamping(collideDamping);
    psystem->setCollideShear(collideShear);
    psystem->setCollideAttraction(collideAttraction);
    psystem->update(timestep);
    psystem->dumpParticles();
}

In particleSystem.cpp method dumpParticles(),

void
ParticleSystem::dumpParticles()
{
   
    uint start = 0;
    uint count = 16384;
    // debug
    copyArrayFromDevice(m_hPos, 0, &m_cuda_posvbo_resource, sizeof(float)*4*count);
    copyArrayFromDevice(m_hVel, m_dVel, 0, sizeof(float)*4*count);
       
    for (uint i=start; i<start+count; i++)
    {
	xfile << m_hPos[i*4+0] << ":";
	yfile << m_hPos[i*4+1] << ":";
	zfile << m_hPos[i*4+2] << ":";
    }
    xfile << std::endl;
    yfile << std::endl;
    zfile << std::endl;

}

The first copyArrayFromDevice call fails with

CUDA error at particleSystem_cuda.cu:90 code=400(cudaErrorInvalidResourceHandle) "cudaGraphicsMapResources(1, cuda_vbo_resource, 0)"

Any ideas why this could be?

Note: if I enable initGL call and set bUseOpenGL to true everything works fine.

I am using Jetson Nano,

R32 (release), REVISION: 4.4, EABI: aarch64, DATE: Fri Oct 16 19:44:43 UTC 2020

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Wed_Oct_23_21:14:42_PDT_2019
Cuda compilation tools, release 10.2, V10.2.89