Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not working with Pytorch

See original GitHub issue

Describe the bug

Whenever a file imports pytorch, it produces an error.

Traceback (most recent call last):
  line 3, in <module>
  File "/home/ayb/.local/anaconda3/envs/deep-learning/lib/python3.8/site-packages/torch/", line 447, in <module>
    from .tensor import Tensor
  File "/home/ayb/.local/anaconda3/envs/deep-learning/lib/python3.8/site-packages/torch/", line 13, in <module>
    from torch.overrides import (
  File "/home/ayb/.local/anaconda3/envs/deep-learning/lib/python3.8/site-packages/torch/", line 1212, in <module>
    has_torch_function = _add_docstr(
RuntimeError: function '_has_torch_function' already has a docstring

To Reproduce Open AREPL with a file imports pytorch with

import torch

Screenshots If applicable, add screenshots to help explain your problem.


Other Information (please complete the following information):

  • OS: Ubuntu 20.04
  • Python Version: 3.8.4 (conda)
  • PyTorch version: 1.8.1

It actually works for the first time it runs, then produces this error.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

Almenoncommented, Jun 6, 2021

Unfortunately doesn’t look like there’s a easy solution to this… the docstring gets added in C code, and I’m not a C expert. See

Possibly related:

Almenoncommented, Mar 14, 2022

Good workaround. When the library is in there AREPL starts completely fresh each time.

On Mon, Mar 14, 2022, 7:54 AM Jaideep Singh Heer @.***> wrote:

numpy still loads twice for some reason.

— Reply to this email directly, view it on GitHub, or unsubscribe . Triage notifications on the go with GitHub Mobile for iOS or Android

You are receiving this because you commented.Message ID: @.***>

Read more comments on GitHub >

github_iconTop Results From Across the Web

Import torch not working - PyTorch Forums
Hi, I'm an artist, not a programmer, and I'm trying to install pytorch to install a neural network style transfer software, following this...
Read more >
CUDA 11.4 and torch version 1.11.0 not working - PyTorch Live
Hi there, I have CUDA 11.4 and I've installed pytorch 1.11.0. I thought these versions where compatible but I get this error when...
Read more >
PyTorch pip installation not working - windows
Trying to install PyTorch with the given command from the homepage with Stable, Windows, Pip, Python and Cuda 11.3. The command I get...
Read more >
2. Troubleshooting Guide - PyTorch
Refer to this section for common issues faced while deploying your Pytorch models using Torchserve and their corresponding troubleshooting steps.
Read more >
Issue with pip installation of PyTorch
A few months ago, I installed chemprop via Visual Studio Code, Windows 10 64 bit). The installation instructions say:
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found