tensorflow 中对 tf.estimator 分配 多GPU 方法

1 通用分配GPU:

import os
os.environ['CUDA_VISIBLE_DEVICES'] = '1,2'

2 有些使用上述方法不可取,需要从代码中指定分配GPU:

  session_config = tf.ConfigProto(device_count={'GPU': 0,'GPU':1,'GPU':2})

  #session_config.gpu_options.per_process_gpu_memory_fraction = 0.9
  #session_config.gpu_options.allow_growth = True
  #session_config.gpu_options.allocator_type = 'BFC'

  run_config = tf.estimator.RunConfig().replace(session_config=session_config)

  estimator = tf.estimator.Estimator(
      model_fn=model_fn, model_dir=FLAGS.model_dir, config=run_config, params=params)
上述代码的注释细节表示每块GPU利用的具体配置。如果需要在tf.estimator 使用多GPU ,需要注释掉这些配置,也就是上述代码注释部分需要注释掉。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值