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 2022/09/23 02:50:09 UTC

[GitHub] [tvm] DzAvril opened a new pull request, #12881: [Runtime] Release temp param buffer after creating graph executor.

DzAvril opened a new pull request, #12881:
URL: https://github.com/apache/tvm/pull/12881

   ```c++
   Module GraphExecutorFactory::ExecutorCreate(const std::vector<Device>& devs) {
     auto exec = make_object<GraphExecutor>();
     exec->Init(this->graph_json_, this->imports_[0], devs, PackedFunc());
     // set params
     SetParams(exec.get(), this->params_);
     return Module(exec);
   }
   ```
   In the code block above, `params_` is defined as `std::unordered_map<std::string, tvm::runtime::NDArray>` and holds a copy of parameters deserialized from DSO model. After creating the graph executor this copy of parameters still resides in memory. It will waste lots of memory usage if the model is big.
   Take `resnet101` as an example. The size of the parameters is about 170.49 MB. The picture below is the reported memory map of the process which inference with `resnet101`. The RSS in the anonymous mapping space is about 350 MB.
   ![image](https://user-images.githubusercontent.com/18597737/191883103-02ab8e30-966f-4ee7-95fe-f3c3bd3b4a9d.png)
   
   We can release `this->params_` by `this->params_.clear()`. After release, the RSS decreases to 180 MB.
   ![image](https://user-images.githubusercontent.com/18597737/191882947-59b2a1d7-f381-4c52-819f-3437bbe16041.png)
   


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org