tensorflow 指定GPU

来源:互联网 发布:新西兰林肯大学 知乎 编辑:程序博客网 时间:2024/05/19 17:59

2 python代码中设置使用的GPU

如果要在python代码中设置使用的GPU(如使用pycharm进行调试时),可以使用下面的代码(见第二个参考网址中Yaroslav Bulatov的回复):

import osos.environ["CUDA_VISIBLE_DEVICES"] = "2"