Hi,
I want to know how to release ALL CUDA GPU memory used for a Libtorch Module ( torch::nn::Module ). I created a new class A that inherits from Module. This class have other registered modules inside. I cannot release a module basic-class instance as nn::Conv2d.
To start I will ask  for a simple case of how to release a simple instance of nn::Conv2d that has its memory in a CUDA GPU. Here an example :
int gpu_id = 0;
auto deviceCUDA = torch::Device(torch::kCUDA, gpu_id);
int c_in = 1000;
int c_out = 1000;
auto conv1 = nn::Conv2d(nn::Conv2dOptions(c_in, c_out, torch::ExpandingArray<2>(3)).stride(torch::ExpandingArray<2>(2)).padding(torch::ExpandingArray<2>(1)).bias(false));
	
conv1->to(deviceCUDA);

// HERE : RELEASE CUDA-GPU-CODE OF  conv1

I tried using : c10::cuda::CUDACachingAllocator::emptyCache();
But it is not enough . It releases a small cache memory .
Also , I would like to know, if there is a methodology to release memory using Libtorch C++ Modules , specifically CUDA GPU Memory .
Thanks a lot .