You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2020/09/29 13:54:55 UTC

[GitHub] [incubator-tvm] jamesqiao opened a new issue #6590: How to free memory manually after building a operator for long running building case?

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:
users@infra.apache.org



[GitHub] [incubator-tvm] tqchen commented on issue #6590: How to free memory manually after building a operator for long running building case?

Posted by GitBox <gi...@apache.org>.
tqchen commented on issue #6590:
URL: https://github.com/apache/incubator-tvm/issues/6590#issuecomment-700875357


   Thanks for reporting the problem, please open a new thread on https://discuss.tvm.apache.org/. BTW, checking a modified version of the script on master seems to show a stable memory usage.
   
   ```python
   import os, psutil
   import tvm
   from tvm import te
   
   def tvm_build():
       n = 2
       A = te.placeholder((n,), name='A')
       B = te.placeholder((n,), name='B')
       C = te.compute(A.shape, lambda *i: A(*i) + B(*i), name='C')
       s = te.create_schedule(C.op)
       m = tvm.driver.lower(s, [A, B, C], name="test_add")
       rt_mod = tvm.driver.build(m, target="llvm")
   
   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')
   
   
   main()
   ```


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [incubator-tvm] tqchen closed issue #6590: How to free memory manually after building a operator for long running building case?

Posted by GitBox <gi...@apache.org>.
tqchen closed issue #6590:
URL: https://github.com/apache/incubator-tvm/issues/6590


   


----------------------------------------------------------------
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:
users@infra.apache.org