在编辑器窗口上运行文件时,多次导入pytorch会在IPython控制台中导致运行时错误。
我正在使用pytorch 0.4.0。
期待没有例外。 但是某些编译/重新加载现有模块似乎会导致错误。
请注意,以下步骤是肮脏的怪异解决方案。
Traceback (most recent call last):
File "<ipython-input-3-bc7ab1fdfb9b>", line 1, in <module>
runfile('/Users/aaa/.spyder-py3/temp.py', wdir='/Users/aaa/.spyder-py3')
File "/usr/local/lib/python3.6/site-packages/spyder/utils/site/sitecustomize.py", line 705, in runfile
execfile(filename, namespace)
File "/usr/local/lib/python3.6/site-packages/spyder/utils/site/sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "/Users/aaa/.spyder-py3/temp.py", line 7, in <module>
import torch
File "/usr/local/lib/python3.6/site-packages/torch/__init__.py", line 184, in <module>
from .tensor import Tensor
File "/usr/local/lib/python3.6/site-packages/torch/tensor.py", line 12, in <module>
class Tensor(torch._C._TensorBase):
File "/usr/local/lib/python3.6/site-packages/torch/tensor.py", line 170, in Tensor
""")
RuntimeError: method 'detach' already has a docstring
IPython >=4.0 : 6.3.1 (OK)
cython >=0.21 : 0.28.2 (OK)
jedi >=0.9.0 : 0.12.0 (OK)
nbconvert >=4.0 : 5.3.1 (OK)
numpy >=1.7 : 1.14.1 (OK)
pandas >=0.13.1 : 0.22.0 (OK)
psutil >=0.3 : 5.4.5 (OK)
pycodestyle >=2.3: 2.4.0 (OK)
pyflakes >=0.6.0 : 1.6.0 (OK)
pygments >=2.0 : 2.2.0 (OK)
pylint >=0.25 : 1.8.4 (OK)
qtconsole >=4.2.0: 4.3.1 (OK)
rope >=0.9.4 : 0.10.7 (OK)
sphinx >=0.6.6 : 1.7.4 (OK)
sympy >=0.7.3 : 1.1.1 (OK)
感谢您的举报。 我们将在下一个错误修正版本中解决此问题。
自己注意:我们需要将pytorch添加到UMR黑名单模块列表中。
@dalthviz ,请按照我上面的说明进行此工作。
我在spyder中使用pytorch(由“ pip install --user torch”安装)。 重新运行文件时出现错误(“ RuntimeError:方法'detach'已经具有文档字符串”),但是禁用UMR解决了该问题。 但是,在寻找原因时,我注意到两件事: