2020
09-29
09-29
Keras设定GPU使用内存大小方式(Tensorflow backend)
通过设置Keras的Tensorflow后端的全局变量达到。importosimporttensorflowastfimportkeras.backend.tensorflow_backendasKTFdefget_session(gpu_fraction=0.3):'''Assumethatyouhave6GBofGPUmemoryandwanttoallocate~2GB'''num_threads=os.environ.get('OMP_NUM_THREADS')gpu_options=tf.GPUOptions(per_process_gpu_memory_fraction=gpu_fraction)ifnum_threads:returntf.Session(config=tf.C...
继续阅读 >