Hi,
Thanks for the awesome framework. Recently, I’ve been using pytorch for linear algebra and found a weird memory leak in torch.qr.
I’m using torch.__version__  0.2.0_4 on anaconda python 3.6 CUDA 8.0 using the standard conda installation.
import torch
B = torch.rand(4000, 1000).cuda()   # nvidia-smi output 298MiB
_ = torch.qr(B)   # 388MiB
for i in range(100): torch.qr(B)  # Constantly increases until 1941MiB

compared to
import torch
B = torch.rand(4000, 1000).cuda()   # nvidia-smi output 298MiB
_ = torch.svd(B)   # 399MiB
for i in range(100): torch.svd(B)  # fluctuates between 414 to 432 and back to 414

Aside from that, is there a reason for using Magma instead of cuBLAS?
Thanks!

  
      github.com
  
  
    pytorch/pytorch/blob/1c51c185a1152ae7efe7d8d490102a9cdb7782e7/torch/lib/THC/generic/THCTensorMathMagma.cu#L587 1

if (info < 0)
  THError("MAGMA potrs : Argument %d : illegal value", -info);


THCTensor_(freeCopyTo)(state, b_, rb_);
THCTensor_(free)(state, a_);
#else
THError(NoMagma(potrs));
#endif
}


THC_API void THCTensor_(qr)(THCState *state, THCTensor *rq_, THCTensor *rr_, THCTensor *a_)
{
#ifdef USE_MAGMA
THArgCheck(a_->nDimension == 2, 2, "A should be 2 dimensional");


THCTensor *a = THCTensor_(newColumnMajor)(state, rr_, a_);
int m = a->size[0];
int n = a->size[1];
int k = (m < n ? m : n);


#ifdef MAGMA_V2