Pytorch Docker Installation issue

I am trying to install pytorch 1.12.1 in a docker container.
My host system has the following configurations
Sun Apr 14 19:51:17 2024
±----------------------------------------------------------------------------+
| NVIDIA-SMI 470.82.01 Driver Version: 470.82.01 CUDA Version: 11.4 |
|-------------------------------±---------------------±---------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA RTX A5000 On | 00000000:01:00.0 Off | Off |
| 30% 46C P8 22W / 230W | 13MiB / 24256MiB | 0% Default |
| | | N/A |
±------------------------------±---------------------±---------------------+
| 1 NVIDIA RTX A5000 On | 00000000:21:00.0 Off | Off |
| 30% 37C P8 16W / 230W | 13MiB / 24256MiB | 0% Default |
| | | N/A |
±------------------------------±---------------------±---------------------+
| 2 NVIDIA TITAN V On | 00000000:4C:00.0 Off | N/A |
| 35% 51C P8 29W / 250W | 73MiB / 12057MiB | 0% Default |
| | | N/A |
±------------------------------±---------------------±---------------------+

I am using nvidia/cuda:11.6.1-devel-ubuntu20.04 image and i installed pytorch from pip using
pip install torch==1.12.1+cu116 torchvision==0.13.1+cu116 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu116

i run the container with --gpus all
This is the problem now
print(torch.cuda.is_available())
i get this
/usr/local/lib/python3.8/dist-packages/torch/cuda/init.py:88: UserWarning: CUDA initialization: Unexpected error from cudaGetDeviceCount(). Did you run some cuda functions before calling NumCudaDevices() that might have already set an error? Error 804: forward compatibility was attempted on non supported HW (Triggered internally at …/c10/cuda/CUDAFunctions.cpp:109.)
return torch._C._cuda_getDeviceCount() > 0
False

I have tried a bunch of solution but none worked, has anyone faced a similar issue?