GPU的使用

1、bash中

## bash
设定GPU卡顺序:export CUDA_DEVICE_ORDER = "PCI_BUS_ID"
指定第1块和第2块GPU卡:export CUDA_VISIBLE_DEVICES="0,1" 

2、python代码中

## python

import os

os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"

os.environ["CUDA_VISIBLE_DEVICES"] = "0,2,3"  ,这样就指定了第1,3,4,张卡可见了

设置定量的GPU使用量
config = tf.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction=0.9 # 占用GPU90%的显存
session = tf.Session(config=config)
发布了97 篇原创文章 · 获赞 40 · 访问量 16万+

猜你喜欢

转载自blog.csdn.net/NOT_GUY/article/details/104591913
今日推荐