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

Use CPU instead of unsupported GPU #18

Open
santoshbs opened this issue Aug 1, 2023 · 0 comments
Open

Use CPU instead of unsupported GPU #18

santoshbs opened this issue Aug 1, 2023 · 0 comments

Comments

@santoshbs
Copy link

I have an older NVIDIA GPU that is unfortunately not supported by PyTorch. As such, I was unable to use tweetNLP as it tries to use GPU since torch.cuda.is_available() returns True.

One way I was able to get around was modifying the model.py as follows:

        # GPU setup (https://github.com/cardiffnlp/tweetnlp/issues/15)
        if use_gpu: 
            if torch.cuda.is_available() and torch.cuda.device_count() > 0:
                self.device = torch.device('cuda')
                print('Note: Using GPU') 
            elif hasattr(torch.backends, "mps") and torch.backends.mps.is_available() and torch.backends.mps.is_built():
                self.device = torch.device("mps")
                print('Note: Using MPS') 
            else:
                self.device = torch.device('cpu')
                print('Note: Using CPU') 
        else:
            self.device = torch.device('cpu')
            print('Note: Using CPU') 

Sharing it, just in case it helps someone else encountering a similar situation.

sbs

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

1 participant