You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mxnet.apache.org by TongKe Xue <tk...@tkxue.org> on 2017/10/16 23:15:33 UTC

disposing all ndarray in a given context

Quoting: https://github.com/apache/incubator-mxnet/blob/master/scala-package/core/src/main/scala/ml/dmlc/mxnet/NDArray.scala#L545-L546

* WARNING: it is your responsibility to clear this object through dispose().
* NEVER rely on the GC strategy

Is there a way to say "dispose all ndarrays of this context" ?

Re: disposing all ndarray in a given context

Posted by Joern Kottmann <ko...@gmail.com>.
Have a look at this code:
https://github.com/apache/incubator-mxnet/blob/master/scala-package/core/src/main/scala/ml/dmlc/mxnet/optimizer/AdaDelta.scala

There they have the same problem and use disposeDepsExcept to release resources.

Jörn

On Tue, Oct 17, 2017 at 4:18 PM, TongKe Xue <tk...@tkxue.org> wrote:
> Following up to this:
>
> I see that the Scala API, when creating ndarray, uses:
>
> https://github.com/apache/incubator-mxnet/blob/master/scala-package/core/src/main/scala/ml/dmlc/mxnet/NDArray.scala#L114
>
> which calls
>
> https://github.com/apache/incubator-mxnet/blob/master/scala-package/core/src/main/scala/ml/dmlc/mxnet/LibInfo.scala#L42
>
> to get a "handle" from the given context.
>
>
> I've looked through the LibInfo.scala file -- and it's not clear to me
> if there is a way to:
>
> 1) nuke all handles in a Context OR
> 2) get a list of all handles in a Context (so I can manually call dispose)
>
> Is either of these things possible?
>
> Thanks!
>
>
> On Mon, Oct 16, 2017 at 4:15 PM, TongKe Xue <tk...@tkxue.org> wrote:
>> Quoting: https://github.com/apache/incubator-mxnet/blob/master/scala-package/core/src/main/scala/ml/dmlc/mxnet/NDArray.scala#L545-L546
>>
>> * WARNING: it is your responsibility to clear this object through dispose().
>> * NEVER rely on the GC strategy
>>
>> Is there a way to say "dispose all ndarrays of this context" ?

Re: disposing all ndarray in a given context

Posted by TongKe Xue <tk...@tkxue.org>.
Following up to this:

I see that the Scala API, when creating ndarray, uses:

https://github.com/apache/incubator-mxnet/blob/master/scala-package/core/src/main/scala/ml/dmlc/mxnet/NDArray.scala#L114

which calls

https://github.com/apache/incubator-mxnet/blob/master/scala-package/core/src/main/scala/ml/dmlc/mxnet/LibInfo.scala#L42

to get a "handle" from the given context.


I've looked through the LibInfo.scala file -- and it's not clear to me
if there is a way to:

1) nuke all handles in a Context OR
2) get a list of all handles in a Context (so I can manually call dispose)

Is either of these things possible?

Thanks!


On Mon, Oct 16, 2017 at 4:15 PM, TongKe Xue <tk...@tkxue.org> wrote:
> Quoting: https://github.com/apache/incubator-mxnet/blob/master/scala-package/core/src/main/scala/ml/dmlc/mxnet/NDArray.scala#L545-L546
>
> * WARNING: it is your responsibility to clear this object through dispose().
> * NEVER rely on the GC strategy
>
> Is there a way to say "dispose all ndarrays of this context" ?