在程序中可以按照https://blog.csdn.net/qq_35975447/article/details/104777024,去分配GPU的使用量。
在程序中如下:
import tensorflow as tf
gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.1333)
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True, gpu_options=gpu_options))
# config = tf.ConfigProto()
# config.gpu_options.allow_growth = True
# session = tf.Session(config=config)
1.在命令行指定单个GPU
CUDA_VISIBLE_DEVICES=3 python3 ./train.py
后面想用什么参数,按照原样就可以。
2.在命令行指定多个GPU(待验证)
CUDA_VISIBLE_DEVICES=2,3 python3 ./train.py