3 回答

TA貢獻(xiàn)1784條經(jīng)驗(yàn) 獲得超9個(gè)贊
tf.Session
tf.GPUOptions
config
# Assume that you have 12GB of GPU memory and want to allocate ~4GB:gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.333)sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options))
per_process_gpu_memory_fraction

TA貢獻(xiàn)1898條經(jīng)驗(yàn) 獲得超8個(gè)贊
Deep Learning with TensorFlow
在某些情況下,進(jìn)程只需要分配可用內(nèi)存的子集,或者只在進(jìn)程需要時(shí)增加內(nèi)存使用量。TensorFlow提供 兩種配置會(huì)話中控制此操作的選項(xiàng)。第一個(gè)是 allow_growth
選項(xiàng),它嘗試根據(jù)運(yùn)行時(shí)分配的GPU內(nèi)存,它開(kāi)始分配很少的內(nèi)存,并且隨著會(huì)話的運(yùn)行和需要更多的GPU內(nèi)存,我們擴(kuò)展了TensorFlow進(jìn)程所需的GPU內(nèi)存區(qū)域。
1)允許增長(zhǎng):(更靈活)
config = tf.ConfigProto()config.gpu_options.allow_growth = Truesession = tf.Session(config=config, ...)
per_process_gpu_memory_fraction
each
2)分配固定內(nèi)存:
40%
config = tf.ConfigProto()config.gpu_options.per_process_gpu_memory_fraction = 0.4session = tf.Session(config=config, ...)
注:
添加回答
舉報(bào)