Python Cuda运行时内存不足错误-Pytorch使用8GB

Python Cuda运行时内存不足错误-Pytorch使用8GB,python,pytorch,Python,Pytorch,我正在尝试用我的GTX 1080Ti训练一款具有11GB内存的机型,但Pytorch似乎为自己保留了约8GB内存,我可以通过任何方式减少这个数字吗?(这是最新的) 运行时错误:CUDA内存不足。尝试分配2.53 GiB(GPU 0;10.91 GiB总容量;4.15 GiB已分配;1.73 GiB空闲;PyTorch总共保留8.19 GiB)(malloc at/PyTorch/c10/cuda/CUDACacheGallocator.cpp:289) 帧#0:c10::Error::Error

我正在尝试用我的GTX 1080Ti训练一款具有11GB内存的机型,但Pytorch似乎为自己保留了约8GB内存,我可以通过任何方式减少这个数字吗?(这是最新的)

运行时错误:CUDA内存不足。尝试分配2.53 GiB(GPU 0;10.91 GiB总容量;4.15 GiB已分配;1.73 GiB空闲;PyTorch总共保留8.19 GiB)(malloc at/PyTorch/c10/cuda/CUDACacheGallocator.cpp:289)
帧#0:c10::Error::Error(c10::SourceLocation,std::string const&)+0x46(0x7f54646f7536 in/home/yasin/.local/lib/python3.6/site packages/torch/lib/libc10.so)
帧1:+0x1cf1e(0x7f5464940f1e in/home/yasin/.local/lib/python3.6/site packages/torch/lib/libc10_cuda.so)
帧2:+0x1df9e(0x7f5464941f9e在/home/yasin/.local/lib/python3.6/site packages/torch/lib/libc10_cuda.so中)
帧#3:at::native::empty_cuda(c10::ArrayRef,c10::TensorOptions const&,c10::可选)+0x135(0x7f54005f7535 in/home/yasin/.local/lib/python3.6/site packages/torch/lib/libtorch_cuda.so)
帧4:+0xf7a66b(0x7f53febef66b in/home/yasin/.local/lib/python3.6/site packages/torch/lib/libtorch_cuda.so)
帧#5:+0xfc3f57(0x7f53fec38f57 in/home/yasin/.local/lib/python3.6/site packages/torch/lib/libtorch_cuda.so)
帧6:+0x1075389(0x7f543b173389 in/home/yasin/.local/lib/python3.6/site packages/torch/lib/libtorch\u cpu.so)
帧#7:+0x10756c7(0x7f543b1736c7 in/home/yasin/.local/lib/python3.6/site packages/torch/lib/libtorch_cpu.so)
第8帧:+0xf1557e(0x7f53feb8a57e in/home/yasin/.local/lib/python3.6/site packages/torch/lib/libtorch_cuda.so)
帧9:+0xf18043(0x7f53feb8d043 in/home/yasin/.local/lib/python3.6/site packages/torch/lib/libtorch\u cuda.so)
帧#10:at::native::cudnn_卷积(向后)输入(c10::ArrayRef,at::Tensor const&,at::Tensor const&,c10::ArrayRef,c10::ArrayRef,long,bool,bool)+0xb2(0x7f53feb8d882 in/home/yasin/.local/lib/python3.6/site packages/torch/lib/libtorch\u cuda.so)
第11帧:+0xf7f3a0(0x7f53febf43a0 in/home/yasin/.local/lib/python3.6/site packages/torch/lib/libtorch_cuda.so)
帧12:+0xfc3c38(0x7f53fec38c38 in/home/yasin/.local/lib/python3.6/site packages/torch/lib/libtorch\u cuda.so)
帧#13:at::native::cudnn_卷积(at::Tensor const&,at::Tensor const&,at::Tensor const&,c10::ArrayRef,c10::ArrayRef,c10::ArrayRef,long,bool,bool,std::array)+0x4fa(0x7f53feb8ef1a in/home/yasin/.local/lib/python3.6/site packages/torch/lib/libtorch\u cuda.so)
帧#14:+0xf7f6cb(0x7f53febf46cb in/home/yasin/.local/lib/python3.6/site packages/torch/lib/libtorch_cuda.so)
帧15:+0xfc3c94(0x7f53fec38c94 in/home/yasin/.local/lib/python3.6/site packages/torch/lib/libtorch_cuda.so)
帧#16:+0x2c809b6(0x7f543cd7e9b6 in/home/yasin/.local/lib/python3.6/site packages/torch/lib/libtorch_cpu.so)
帧17:+0x2cd0444(0x7f543cdce444 in/home/yasin/.local/lib/python3.6/site packages/torch/lib/libtorch\u cpu.so)
帧#18:torch::autograd::generated::cudnconvolutionbackward::apply(std::vector)


你累了吗
torch.cuda.empty\u cache()
?或者重新启动会话并重新运行代码?您使用的是哪种cuda和pytorch版本?我在cuda 10.2和pytorch 1.5上也遇到了同样的问题。解决这个问题是否顺利?在Windows中也存在这个问题,但讽刺的是,如果我使用较低规格的GPU在Google Colab中进行操作,它会起作用。这里的版本也是1.5。您累了吗
torch.cuda.empty_缓存()
?或者重新启动您的会话并重新运行您的代码?您使用的是什么cuda和pytorch版本?我在cuda 10.2和pytorch 1.5上遇到了相同的问题。解决这个问题是否顺利?在Windows中也有这个问题,但讽刺的是,如果我在Google Colab中使用较低规格的GPU进行操作,它会起作用。这里也有版本1.5。
 RuntimeError: CUDA out of memory. Tried to allocate 2.53 GiB (GPU 0; 10.91 GiB total capacity; 4.15 GiB already allocated; 1.73 GiB free; 8.19 GiB reserved in total by PyTorch) (malloc at /pytorch/c10/cuda/CUDACachingAllocator.cpp:289)

frame #0: c10::Error::Error(c10::SourceLocation, std::string const&) + 0x46 (0x7f54646f7536 in /home/yasin/.local/lib/python3.6/site-packages/torch/lib/libc10.so)
    frame #1: <unknown function> + 0x1cf1e (0x7f5464940f1e in /home/yasin/.local/lib/python3.6/site-packages/torch/lib/libc10_cuda.so)
    frame #2: <unknown function> + 0x1df9e (0x7f5464941f9e in /home/yasin/.local/lib/python3.6/site-packages/torch/lib/libc10_cuda.so)
    frame #3: at::native::empty_cuda(c10::ArrayRef<long>, c10::TensorOptions const&, c10::optional<c10::MemoryFormat>) + 0x135 (0x7f54005f7535 in /home/yasin/.local/lib/python3.6/site-packages/torch/lib/libtorch_cuda.so)
    frame #4: <unknown function> + 0xf7a66b (0x7f53febef66b in /home/yasin/.local/lib/python3.6/site-packages/torch/lib/libtorch_cuda.so)
    frame #5: <unknown function> + 0xfc3f57 (0x7f53fec38f57 in /home/yasin/.local/lib/python3.6/site-packages/torch/lib/libtorch_cuda.so)
    frame #6: <unknown function> + 0x1075389 (0x7f543b173389 in /home/yasin/.local/lib/python3.6/site-packages/torch/lib/libtorch_cpu.so)
    frame #7: <unknown function> + 0x10756c7 (0x7f543b1736c7 in /home/yasin/.local/lib/python3.6/site-packages/torch/lib/libtorch_cpu.so)
    frame #8: <unknown function> + 0xf1557e (0x7f53feb8a57e in /home/yasin/.local/lib/python3.6/site-packages/torch/lib/libtorch_cuda.so)
    frame #9: <unknown function> + 0xf18043 (0x7f53feb8d043 in /home/yasin/.local/lib/python3.6/site-packages/torch/lib/libtorch_cuda.so)
    frame #10: at::native::cudnn_convolution_backward_input(c10::ArrayRef<long>, at::Tensor const&, at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, long, bool, bool) + 0xb2 (0x7f53feb8d882 in /home/yasin/.local/lib/python3.6/site-packages/torch/lib/libtorch_cuda.so)
    frame #11: <unknown function> + 0xf7f3a0 (0x7f53febf43a0 in /home/yasin/.local/lib/python3.6/site-packages/torch/lib/libtorch_cuda.so)
    frame #12: <unknown function> + 0xfc3c38 (0x7f53fec38c38 in /home/yasin/.local/lib/python3.6/site-packages/torch/lib/libtorch_cuda.so)
    frame #13: at::native::cudnn_convolution_backward(at::Tensor const&, at::Tensor const&, at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, long, bool, bool, std::array<bool, 2ul>) + 0x4fa (0x7f53feb8ef1a in /home/yasin/.local/lib/python3.6/site-packages/torch/lib/libtorch_cuda.so)
    frame #14: <unknown function> + 0xf7f6cb (0x7f53febf46cb in /home/yasin/.local/lib/python3.6/site-packages/torch/lib/libtorch_cuda.so)
    frame #15: <unknown function> + 0xfc3c94 (0x7f53fec38c94 in /home/yasin/.local/lib/python3.6/site-packages/torch/lib/libtorch_cuda.so)
    frame #16: <unknown function> + 0x2c809b6 (0x7f543cd7e9b6 in /home/yasin/.local/lib/python3.6/site-packages/torch/lib/libtorch_cpu.so)
    frame #17: <unknown function> + 0x2cd0444 (0x7f543cdce444 in /home/yasin/.local/lib/python3.6/site-packages/torch/lib/libtorch_cpu.so)
    frame #18: torch::autograd::generated::CudnnConvolutionBackward::apply(std::vector<at::Tensor, std::allocator<at::Tensor> >&&) + 0x378 (0x7f543c996918 in /home/yasin/.local/lib/python3.6/site-packages/torch/lib/libtorch_cpu.so)
    frame #19: <unknown function> + 0x2d89c05 (0x7f543ce87c05 in /home/yasin/.local/lib/python3.6/site-packages/torch/lib/libtorch_cpu.so)
    frame #20: torch::autograd::Engine::evaluate_function(std::shared_ptr<torch::autograd::GraphTask>&, torch::autograd::Node*, torch::autograd::InputBuffer&) + 0x16f3 (0x7f543ce84f03 in /home/yasin/.local/lib/python3.6/site-packages/torch/lib/libtorch_cpu.so)
    frame #21: torch::autograd::Engine::thread_main(std::shared_ptr<torch::autograd::GraphTask> const&, bool) + 0x3d2 (0x7f543ce85ce2 in /home/yasin/.local/lib/python3.6/site-packages/torch/lib/libtorch_cpu.so)
    frame #22: torch::autograd::Engine::thread_init(int) + 0x39 (0x7f543ce7e359 in /home/yasin/.local/lib/python3.6/site-packages/torch/lib/libtorch_cpu.so)
    frame #23: torch::autograd::python::PythonEngine::thread_init(int) + 0x38 (0x7f545f97b4d8 in /home/yasin/.local/lib/python3.6/site-packages/torch/lib/libtorch_python.so)
    frame #24: <unknown function> + 0xbd6df (0x7f54675c86df in /usr/lib/x86_64-linux-gnu/libstdc++.so.6)
    frame #25: <unknown function> + 0x76db (0x7f546c2ff6db in /lib/x86_64-linux-gnu/libpthread.so.0)
    frame #26: clone + 0x3f (0x7f546c63888f in /lib/x86_64-linux-gnu/libc.so.6)