However after some time, suddenly, my code freezes when I increase the number of GPUs to more than 2 GPUs.

At what point does the training get stuck? Do you have any logs outputted until the point the training gets stuck (ideally with NCCL_DEBUG=WARN)?
Also how many GPUs does this host have? Do you run into the same issue on other multi-GPU hosts as well?

I assume some synchronization problems might be occurring with more than 2 GPUs

This usually only becomes a major issue at much larger numbers of GPUs, so it should be able to handle more than 2. Are there any factors that could cause synchronization issues, such as some GPUs being significantly slower than others/other jobs or processes using those GPUs while you were training?