zheng-da commented on issue #13658: Converting MX array to DLPack crashes when 
MX array goes out-of-scope
URL: 
https://github.com/apache/incubator-mxnet/issues/13658#issuecomment-447864241
 
 
   the error might be trickier. For DGL code below, the code is 
undeterministic. We have to run it multiple times before we can see crash. It 
seems that some memory in dlpack exported from MXNet isn't referenced. However, 
if I use `mx.nd.from_dlpack(dl)`, it works fine. @wkcn do you have any 
suggestions?
   
   ```python
   import os
   os.environ['DGLBACKEND'] = 'mxnet'
   import mxnet as mx
   import numpy as np
   import dgl
   
   def foo():
       x = mx.nd.array([0, 5], dtype='int64')
       dl = x.to_dlpack_for_read()
       return dgl.ndarray.from_dlpack(dl)
   
   for i in range(10):
       y = foo()
       y.asnumpy()
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to