Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"torch" error by just importing Detoxify #97

Open
IskandarAlex2 opened this issue Nov 6, 2023 · 1 comment
Open

"torch" error by just importing Detoxify #97

IskandarAlex2 opened this issue Nov 6, 2023 · 1 comment

Comments

@IskandarAlex2
Copy link

Python: 3.10.9
I am getting AttributeError: module 'torch' has no attribute 'no_grad' error when trying to run a simple code, following the short guide inside read me. I am new to Python, I am sorry if my mistake is too obvious.

from detoxify import Detoxify
results = Detoxify('original').predict('example text')

print(results)

Full error:

Traceback (most recent call last):
  File "G:\Deving\Saihex\BOSS-FEEDBACK-BACKEND\index.py", line 1, in <module>     
    from detoxify import Detoxify
  File "C:\Py3.10.9\lib\site-packages\detoxify\__init__.py", line 1, in <module>  
    from .detoxify import (
  File "C:\Py3.10.9\lib\site-packages\detoxify\detoxify.py", line 73, in <module> 
    class Detoxify:
  File "C:\Py3.10.9\lib\site-packages\detoxify\detoxify.py", line 112, in Detoxify
    @torch.no_grad()
AttributeError: module 'torch' has no attribute 'no_grad'
@laurahanu
Copy link
Collaborator

You probably have to install/update your torch version! Try pip install --upgrade torch torchvision or follow the instructions on the pytorch website

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants