Code unable to communicate with GPU

When attempting to run some custom code on a machine equipped with an RTX3060, driver version 470.82 and cuda 11.4 the program crashes at the first attempt to acess the GPU.
cudaMemGetInfo returns a garbage value and if cudaPeekAtLastError is run an unknown error is returned.
Simple example code runs fine on the same machine
The same code runs fine on machines using rtx2080 GPUS with CUDA 10.2 and driver version 460, but not with cuda 11.
When using driver version 495 with the 3060 the program crashes as described here
nvidia-smi report appears sane.
What should I try next?