xiximayou

1、如果只需要使用一块显卡

device = torch.device(\'cuda\' if torch.cuda.is_available() else \'cpu\')

2、指定使用多块显卡:在python文件中指定

import os
os.environ[\'CUDA_VISIBLE_DEVICES\'] = \'0,1\'

3、在命令行中指定

CUDA_VISIBLE_DEVICES=0,1 python train.py

清空显存:

torch.cuda.empty_cache()

colab中默认是只有一块卡的。

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-16
  • 2021-05-10
  • 2022-12-23
  • 2021-11-30
  • 2021-07-25
  • 2022-01-01
猜你喜欢
  • 2021-11-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-24
  • 2021-11-13
  • 2021-11-19
相关资源
相似解决方案