jamesqiao opened a new issue #6590:
URL: https://github.com/apache/incubator-tvm/issues/6590


   Hello all,
          I have a sample code from tvm offical site below. I want to build 
thousands of operators in the same process. But i found there is memory leak 
and the memory usage is increasing. I thought after the build of one operator 
was finished, the corresponding resource should be freed. Do you have any 
advice? Can i free memory manually after building a operator? 
          Thanks a lot in advance!
   
   Sample code:
   `
   import os, psutil
   import tvm
   
   
   def tvm_build():
       n = 2
       A = tvm.placeholder((n,), name='A')
       B = tvm.placeholder((n,), name='B')
       C = tvm.compute(A.shape, lambda *i: A(*i) + B(*i), name='C')
       s = tvm.create_schedule(C.op)
       m = tvm.lower(s, [A, B, C], name="test_add")
       rt_mod = tvm.build(m, target="llvm")
       print("ref of tvm, before=" + str(sys.getrefcount(tvm)))
       del tvm
       print("ref of tvm, after=" + str(sys.getrefcount(tvm)))
   
   def main():
       process = psutil.Process(os.getpid())
       for i in range(0, 1000):
           tvm_build()
           print('i='+str(i)+', Used Memory:', process.memory_info().rss / 1024 
/ 1024, 'MB')
   `


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to