Installing cuda on ubuntu jammy 22.04 wont work cannot allocate mem on device but can compile

I go through the installation instruction on the developer guide and it wont work.

i cloned the samples folder and tried to run the c++ 11 sample program and this is the error although the make file builds a binary to run


~/system/cuda-samples/Samples/0_Introduction/c++11_cuda$ ./c++11_cuda 
CUDA error at ../../../Common/helper_cuda.h:796 code=100(cudaErrorNoDevice) "cudaGetDeviceCount(&device_count)"

I tried to run a thrust program and this is the error:

~/system/cuda-samples/Samples/0_Introduction/c++11_cuda$ ./c++11_cuda 
CUDA error at ../../../Common/helper_cuda.h:796 code=100(cudaErrorNoDevice) "cudaGetDeviceCount(&device_count)"

when i try to do a local install based on the developer instructions it seems to install but when i tried to compile with nvcc compiler it says nvcc doesnt exist. the only way to get the compiler working and compiling files is through sudo apt install nvidia-cuda-toolkit which auto installs 11.5. I have tried installing downgrading versions and everything ive seen from search and this happens nvcc not found install toolkit and these compilation error i posted above. I have a jetson xavier and never had these issues. help appreciated