当我尝试创建一个cv :: Mat并在之后发布它(下面的代码)时,我仍然(根据valgrind)内存泄漏大约每个像素1个字节.
有谁知道如何正确释放cv :: Mat的记忆?
谢谢你的激情:)
码:
int main(int argc, char** argv)
{
cv::Mat* matrx = new cv::Mat(1000,1000,CV_8UC1,0.);
matrx->release();
delete matrx;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
Valgrind的:
[...]
==29420== 1,000,028 bytes in 1 blocks are definitely lost in loss record 372 of 372
==29420== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==29420== by 0x5438877: cv::fastMalloc(unsigned long) (in /usr/lib/x86_64-linux-gnu/libopencv_core.so.2.4.8)
==29420== by 0x536FE2A: cv::Mat::create(int, int const*, int) (in /usr/lib/x86_64-linux-gnu/libopencv_core.so.2.4.8)
==29420== by 0x426FB5: cv::Mat::create(int, int, int) (mat.inl.hpp:663)
==29420== by 0x426ECD: cv::Mat::Mat(int, int, int, cv::Scalar_<double> const&) (mat.inl.hpp:347) …Run Code Online (Sandbox Code Playgroud) 在Pytorch-Lightning中,您通常不必指定 cuda 或 gpu。torch.normal但是当我想使用我创建一个高斯采样张量时
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
Run Code Online (Sandbox Code Playgroud)
那么,我必须如何更改才能torch.normal使 pytorch-lightning 正常工作?因为我在 cpu和gpu上的不同机器上使用代码
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
Run Code Online (Sandbox Code Playgroud)