I have 3 gpu, why torch.cuda.device_count() only return '1'

Do you have CUDA_VISIBLE_DEVICES set in the environment from which you launch your program (or by some script that launches your python program)? That makes other devices disappear from subsequent cuda calls, including from pytorch. This illustrates nicely how CUDA_VISIBLE_DEVICES works.