Failed to initialize NVML: Driver/library version mismatch

I write a dockerfile to build a docker image. This docker image has installed cuda drivers with older verisions. So I need to uninstall them, and install some newer ones. Here is the part of the dockerfile.

ENTRYPOINT [ "/bin/bash", "-l", "-c" ]
RUN sudo yum remove -y xorg-x11-drv-nvidia nvidia-kmod cuda-drivers /usr/local/cuda-10.0
RUN rm -rf /usr/local/cuda-10.0
RUN wget https://developer.download.nvidia.com/compute/cuda/11.4.1/local_installers/cuda-repo-rhel7-11-4-local-11.4.1_470.57.02-1.x86_64.rpm
RUN sudo rpm -i cuda-repo-rhel7-11-4-local-11.4.1_470.57.02-1.x86_64.rpm
RUN sudo yum -y install nvidia-driver-latest-dkms cuda cuda-drivers; sudo yum clean all;
RUN sudo nvidia-smi
RUN export PATH=/usr/local/cuda-11.4/bin${PATH:+:${PATH}}
RUN export LD_LIBRARY_PATH=/usr/local/cuda-11.4/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
RUN wget http://developer.download.nvidia.com/compute/redist/cudnn/v8.2.2/cudnn-11.4-linux-x64-v8.2.2.26.tgz
RUN tar -zxf cudnn-11.4-linux-x64-v8.2.2.26.tgz
RUN sudo cp cuda/include/cudnn*.h /usr/local/cuda/include && sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda/lib64 && sudo chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*
RUN export LIBRARY_PATH=/usr/local/cuda/lib64${LIBRARY_PATH:+:${LIBRARY_PATH}}
RUN cd .. && rm -rf cuda && rm -rf cudnn-11.4-linux-x64-v8.2.2.26.tgz
RUN pip install torch==1.9.0 torchvision==0.10.0 torchaudio==0.9.0

However, after building the image, I find an error when call nvidia-smi:

Failed to initialize NVML: Driver/library version mismatch

Could you give me any advice to fix this problem? Thanks a lot.