方法一:
直接在命令窗口指定
CUDA_VISIBLE_DEVICES=1 python train.py
方法二:
在程序中指定
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "3"
如果禁用GPU:
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
参考资料:
[1] https://www.cnblogs.com/darkknightzh/p/6836568.html
[2] https://www.cnblogs.com/tyty-Somnuspoppy/p/10071716.html