NVML library reporting incorrect GPU count

I have supermicro system with the ubuntu running on it,
Linux node-225 4.4.0-62-generic #83-Ubuntu SMP Wed Jan 18 14:10:15 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

I have two NVIDIA GPUs. Through some pcie switch I can able to hotplug the GPU’s to the required host. I’m doing the same thing with the above system.

I’m querying the NVML library about the device info in a successive manner. When I tried to hotplug new GPU to the system, the new gpu information is not reporting by the nvml. But the nvidia-smi works just fine.

PS: I’m doing hotplug during nvml query.