如果torch.cuda.is_available() 返回False,那么可能是你的 CUDA 环境没有正确配置。 检查代码中设备(device)的指定是否合法: 在你的代码中,确保你指定的 GPU 设备编号在有效范围内(0 到 num_gpus-1)。例如: python num_gpus = torch.cuda.device_count() device = torch.device(f"cuda:{0}" if num_g...
if torch.cuda.device_count() > 1: print("Let's use", torch.cuda.device_count(), "GPUs!") #可以在添加第二个参数:device_ids=[0, 1, 2],表示只在第0,1,2块上做训练 #默认是在所有显卡上 model = nn.DataParallel(model) device = torch.device("cuda:0" if torch.cuda.is_available() ...
🐛 Describe the bug when i run ChatGPT : python train_prompts.py prompts.csv --strategy naive get : site-packages/transformers/models/gpt2/modeling_gpt2.py", line 181, in _attn attn_weights = torch.matmul(query, key.transpose(-1, -2)) Run...