提交 b0bf8695 authored 作者: Frederic Bastien's avatar Frederic Bastien

optimized memory usage on the gpu: when used gpu_shared_var.value = ndarray, we…

optimized memory usage on the gpu: when used gpu_shared_var.value = ndarray, we keep only one memory region on the gpu.
上级 a569f569
......@@ -6,6 +6,7 @@ from type import Type
import sys, traceback
from copy import copy
from theano.gof.python25 import all
import numpy
__excepthook = sys.excepthook
def thunk_hook(type, value, trace):
......@@ -157,6 +158,12 @@ class Container(object):
if value is None:
self.storage[0] = None
return
if self.type.__class__.__name__ == "CudaNdarrayType" and isinstance(value,numpy.ndarray):
#The filter method of CudaNdarray alloc a new memory region on the gpu.
#The ref count will be decremented after that.
#That cause 2 region allocated at the same time!
#We decrement the memory reference conter now to try to lower the memory usage.
self.storage[0] = None
if self.strict:
self.storage[0] = self.type.filter(value, strict = True)
else:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论