Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[Feature Request] Release gpu memory by API. #13482

Closed
ducheng678 opened this issue Nov 30, 2018 · 27 comments
Closed

[Feature Request] Release gpu memory by API. #13482

ducheng678 opened this issue Nov 30, 2018 · 27 comments

Comments

@ducheng678
Copy link

ducheng678 commented Nov 30, 2018

Description

When it is required to do a forward propagation at first, and then do another one in the same process,
if gpu memory malloced by the first propagation can not be released, the second one will not have enough memory to use.

@vrakesh
Copy link
Contributor

vrakesh commented Nov 30, 2018

@DuCheng2018 Thank you for the feature, request.

@vrakesh
Copy link
Contributor

vrakesh commented Nov 30, 2018

@mxnet-label-bot add [Feature Request]

@zhreshold
Copy link
Member

zhreshold commented Nov 30, 2018

I am getting multiple(> 5 times) requests similar to this one, I think we need a formal C API as well as python API so user can explicitly release gpu memory pool without waiting for program to exit.

@haoxintong
Copy link

+1, for some application it is necessary to release gpu memory.

@ducheng678 ducheng678 changed the title [Feature Request] Release gpu memory by cpp interface. [Feature Request] Release gpu memory by API. Dec 5, 2018
@relaxli00
Copy link

+1, yes, this is a function needed badly

@ghost
Copy link

ghost commented Dec 6, 2018

+1

@hdjsjyl
Copy link

hdjsjyl commented Dec 6, 2018

+1

3 similar comments
@kohillyang
Copy link

+1

@HermanLiu1
Copy link

+1

@fallingdust
Copy link

+1

@fe-codes
Copy link

+1

12 similar comments
@cgraywang
Copy link
Contributor

+1

@Shicc
Copy link

Shicc commented May 8, 2019

+1

@yuyijie1995
Copy link

+1

@qdLMF
Copy link

qdLMF commented Jul 11, 2019

+1

@evi-Genius
Copy link

+1

@Wondersui
Copy link

+1

@anonymouslycn
Copy link

+1

@khui
Copy link

khui commented Aug 29, 2019

+1

@hgt312
Copy link
Contributor

hgt312 commented Sep 5, 2019

+1

@smartwell
Copy link

+1

@Kongsea
Copy link

Kongsea commented Sep 25, 2019

+1

@ducnguyen96
Copy link

+1

@wkcn
Copy link
Member

wkcn commented Oct 25, 2019

Hi, there.
Thank @vladoovtcharov for adding this API for GPU memory release.
The API is mx.gpu(0).empty_cache().
Firstly, we should set the environment variable MXNET_GPU_MEM_POOL_TYPE to use GPU memory pool.

Here is an example:

# MXNET_GPU_MEM_POOL_TYPE=Round python
Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 19:07:31)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mxnet as mx
>>> a = mx.nd.zeros((10000, 30000), ctx=mx.gpu(0)) + 1
[14:56:53] src/storage/storage.cc:110: Using GPUPooledRoundedStorageManager.
>>> del a
>>> mx.gpu(0).empty_cache()

In my test, the most GPU memory will be released after calling this API, although there is still around 600Mib memory cache.

@szha
Copy link
Member

szha commented Oct 27, 2019

This API only releases the cache in the GPU memory pool. It doesn't release the NDArray cache held by CachedOp

@ymzx
Copy link

ymzx commented Dec 3, 2019

+1

@zhreshold
Copy link
Member

Closing this issue as #14252 is merged, please feel to ping me if you have other thoughts.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests