tensorflow ConfigProto
2018-03-29 09:12
274 查看
tf.ConfigProto一般用在创建
session的时候。用来对
session进行参数配置
with tf.Session(config = tf.ConfigProto(...),...)1
#tf.ConfigProto()的参数 log_device_placement=True : 是否打印设备分配日志 allow_soft_placement=True : 如果你指定的设备不存在,允许TF自动分配设备 tf.ConfigProto(log_device_placement=True,allow_soft_placement=True)1
2
3
4
控制GPU资源使用率
#allow growth config = tf.ConfigProto() config.gpu_options.allow_growth = True session = tf.Session(config=config, ...) # 使用allow_growth option,刚一开始分配少量的GPU容量,然后按需慢慢的增加,由于不会释放 #内存,所以会导致碎片1
2
3
4
5
6
# per_process_gpu_memory_fraction gpu_options=tf.GPUOptions(per_process_gpu_memory_fraction=0.7) config=tf.ConfigProto(gpu_options=gpu_options) session = tf.Session(config=config, ...) #设置每个GPU应该拿出多少容量给进程使用,0.4代表 40%1
2
3
4
5
控制使用哪块GPU
~/ CUDA_VISIBLE_DEVICES=0 python your.py#使用GPU0 ~/ CUDA_VISIBLE_DEVICES=0,1 python your.py#使用GPU0,1 #注意单词不要打错 #或者在 程序开头 os.environ['CUDA_VISIBLE_DEVICES'] = '0' #使用 GPU 0 os.environ['CUDA_VISIBLE_DEVICES'] = '0,1' # 使用 GPU 0,1
相关文章推荐
- Tensorflow ConfigProto & inter_/intra_op_parallelism_threads 整理
- tensorflow ConfigProto
- TensorFlow KeyError: "Couldn't find field google.protobuf.DescriptorProto.ExtensionRange.options"
- Tensorflow protobuf版本报错问题解决(AttributeError: 'module' object has no attribute 'Default')
- TensorFlow Data Input (Part 1): Placeholders, Protobufs & Queues
- TensorFlow Data Input (Part 1): Placeholders, Protobufs & Queues 占位符,原型和队列
- 初窥Tensorflow Object Detection API 源码之(1.2)FeatureExtractor.Config
- 从零开始Windows环境下安装python+tensorflow
- TensorFlow+Python基础知识和基本包的使用
- Tensorflow tf.nn.in_top_k Error targets[0] is out of range
- 欧式距离 caffe tensorflow
- 配置(7) Tensorflow OpKernel ('op: "BestSplits" device_type: "CPU"') for unknown op: BestSplits
- 神经网络之VGGNet模型的实现(Python+TensorFlow)
- Keras + TensorFlow
- Tensorflow RNN_LSTM实例
- CS20SI-tensorflow for research笔记: Lecture2
- TensorflowSharp 简单使用与KNN识别MNIST流程
- Tensorflow embedding小笔记
- tensorflowxun训练自己的数据集之从tfrecords读取数据
- chapter2 of OReilly.Hands-On.Machine.Learning.with.Scikit-Learn.and.TensorFlow