查看机器上GPU情况

命令: nvidia-smi

功能:显示机器上gpu的情况

多显卡服务器指定显卡运行tensorflow程序

其中左上侧有0、1、2、3的编号,表示GPU的编号,在后面指定GPU时需要使用这个编号。

方法一:在终端执行程序时指定GPU  

CUDA_VISIBLE_DEVICES=1   python  your_file.py

这样在跑你的网络之前,告诉程序只能看到1号GPU,其他的GPU它不可见

可用的形式如下:

CUDA_VISIBLE_DEVICES=1           Only device 1 will be seen
CUDA_VISIBLE_DEVICES=0,1         Devices 0 and 1 will be visible
CUDA_VISIBLE_DEVICES="0,1"       Same as above, quotation marks are optional
CUDA_VISIBLE_DEVICES=0,2,3       Devices 0, 2, 3 will be visible; device 1 is masked

CUDA_VISIBLE_DEVICES=""          No GPU will be visible

方法二:在Python代码中指定GPU

import os
os.environ["CUDA_VISIBLE_DEVICES"] = "0"

 

相关文章:

  • 2021-08-16
  • 2022-01-07
  • 2018-02-05
  • 2021-12-07
  • 2021-09-30
猜你喜欢
  • 2021-11-19
  • 2021-11-13
  • 2021-07-21
  • 2022-02-21
  • 2021-06-23
  • 2022-01-31
  • 2021-11-27
相关资源
相似解决方案