lipiji / SongNet

Code for ACL 2020 paper "Rigid Formats Controlled Text Generation":https://www.aclweb.org/anthology/2020.acl-main.68/
MIT License
230 stars 40 forks source link

如何使用多卡训练? #20

Closed ChaooMa closed 3 years ago

ChaooMa commented 3 years ago

尝试把 train.sh 里的 world_size 和 gpus 都设为 8,报了这个错误:

label_smoothing.py", line 15, in init self.one_hot = torch.full((1, size), self.smoothing_value).to(device) RuntimeError: CUDA error: invalid device ordinal

请问应该怎么办啊?

ps:另外发现了一个小问题,无论怎样设置 CUDA_VISIBLE_DEVICES,单卡时总是使用第二个 GPU,正在尝试解决

lipiji commented 3 years ago

都设置8之后 CUDA_VISIBLE_DEVICES这个环境变量也要设置成0,1,2,3,4,5,6,7

ChaooMa commented 3 years ago

都设置8之后 CUDA_VISIBLE_DEVICES这个环境变量也要设置成0,1,2,3,4,5,6,7

设置了,还是显示上述这个错误

lipiji commented 3 years ago

这种错误就是你的gpu id越界了,如果只有一个gpu,那么gpuid=0,如果2两个0,1。