For some reason am not able to access my gpu using torch think it might be dues to cuda 12.2.
Why do you think it would be due to CUDA 12.2?
The PyTorch binaries ship with their own dependency and your locally CUDA toolkit will be used if you build PyTorch from source or custom CUDA extensions.
You would only need to properly install an NVIDIA driver.