Spyder: Multiple loading of pytorch module with script causes RuntimeError on IPython console.

Created on 30 Apr 2018  ·  3Comments  ·  Source: spyder-ide/spyder

Problem Description

Importing pytorch more than twice with running a file on the editor window causes a runtime error in the IPython console.
I'm using pytorch 0.4.0.

What steps will reproduce the problem?

  1. Run Spyder3.
  2. Write 'import torch' in the editor window.
  3. Run the script.
  4. Run the script again.

What is the expected output? What do you see instead?

Expecting no exception. But some compiling/reloading existing module seems to cause an error.
Note that steps below are the dirty weird solution.

  1. Run Spyder3.
  2. Write 'import torch' in the IPython console and press enter.
  3. Write 'import torch' in the editor window.
  4. Run the script.
  5. Run the script again.
    In short, initially loading pytorch module on IPython console solves the problem, but I don't know why.

Paste Traceback/Error Below (if applicable)

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

Package Versions

  • Spyder: 3.2.8
  • Python: 3.6.4
  • Qt:
  • PyQt:
  • Operating System: macOS 10.13.4

Dependencies

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)
IPython Console Bug

All 3 comments

Thanks for reporting. We'll fix this in our next bugfix release.

Note to self: We need to add pytorch to the list of UMR blacklisted modules.

@dalthviz, please work on this one, following my note above.

I am using pytorch in spyder (installed by "pip install --user torch"). I got an error when re-running a file("RuntimeError: method 'detach' already has a docstring"), but disabling UMR resolved the problem. However, while looking for the reason, I noticed two things:

  1. I was not able to add torch to the UMR exclusions in the GUI ("not installed on machine")
  2. In umr.py "pytorch" is hardcoded in the list. I was wondering if this is correct, because it is imported with "import torch"
Was this page helpful?
0 / 5 - 0 ratings