Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [2, 1024, 18, 8, 16]], which is output 0 of ReluBackward0, is at version 1; expected version 0 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True). ubantu
时间: 2024-03-29 19:41:48 浏览: 56
这个错误提示是在 Ubuntu 操作系统下出现的,但是它与操作系统本身没有关系,而是与 PyTorch 库的使用有关。建议在 Ubuntu 系统中安装 PyTorch 库,并按照之前回答的方法,在运行反向传播之前加上自动异常检测的代码,以找到导致梯度计算错误的操作。具体的安装方法可以参考 PyTorch 官方文档。
相关问题
Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass RuntimeError: bad allocation
Variable._execution_engine.run_backward( # Calls into the C engine to run the backward pass RuntimeError: bad allocation是运行反向传播时引发的运行时错误。这个错误通常是由于内存分配问题引起的。可能是你的代码中使用了太多的内存,导致内存不足,无法进行分配。解决这个问题的方法可以是优化代码,减少内存使用量,或者增加可用的内存。
Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass
Variable._execution_engine.run_backward(是一个函数调用,用于运行反向传播过程的C引擎。它在计算图中执行反向传播,并计算梯度。根据引用中的错误信息,出现这个错误的原因是在计算图中的某个张量的梯度要求不需要梯度,但却尝试计算它的梯度。根据引用和引用[4],解决这个问题的方法是确保在构建Variable时,将requires_grad参数设置为True,以便对该变量计算梯度。根据引用,可以使用torch.autograd.Variable来构建Variable,并设置requires_grad=True。这样,就可以解决这个问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span><span class="em">4</span>