查看显卡使用情况:
nvidia-smi
设置显卡号:
export CUDA_VISIBLE_DEVICES=“1”
指定空闲的GPU运行python程序
CUDA_VISIBLE_DEVICES=0,2,3 python test.py
查看是否有可用GPU、可用GPU数量:
torch.cuda.is_available(), torch.cuda.device_count()
或者
import tensorflow as tf
print(tf.test.is_gpu_available())
查看当前使用的GPU序号:
torch.cuda.current_device()