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

Can't instantiate abstract class Classifier with abstract methods forward #7

Closed
e-choness opened this issue Sep 12, 2022 · 5 comments
Closed

Comments

@e-choness
Copy link

Hi

Thank you for this straight forward codes for us to practice fine-tuning models with ViT. I'm on a project that classifying book covers. Everything goes well on my own dataset until trying to define classifier. An error message popped up "Can't instantiate abstract class Classifier with abstract methods forward". As I looked up the pytorch lightning code about forward(), it is indeed an abstract class. No idea why the error since the method was initiated in the init() method.

image

Has anyone run into this issue yet?

@nateraw
Copy link
Owner

nateraw commented Sep 13, 2022

If I were you I would create a new environment, reinstall latest pypi of pytorch-lightning, and see if that solves your issue. I just re-ran the colab notebook and its fine, so there's got to be something wrong with your local environment.

@e-choness
Copy link
Author

If I were you I would create a new environment, reinstall latest pypi of pytorch-lightning, and see if that solves your issue. I just re-ran the colab notebook and its fine, so there's got to be something wrong with your local environment.

Thank you for the quick reply. I installed pytorch-lightning just a few days ago. The issue might be my outdated transformer package. I will try it out and return with the results.

@nateraw
Copy link
Owner

nateraw commented Sep 13, 2022

sounds good! I do think its lightning, though. My guess is a pip install -U pytorch-lightning would fix this.

@e-choness
Copy link
Author

e-choness commented Sep 13, 2022

sounds good! I do think its lightning, though. My guess is a pip install -U pytorch-lightning would fix this.

Thank you! Updated both transformer and pytorch-lightning package. It's no longer an issue. Tuning local environment is a bit of a chore. Also some parameters such as GPU index needs to be adjusted.

@nateraw
Copy link
Owner

nateraw commented Sep 13, 2022

Great! glad it worked out for you. And yea, the gpu stuff should be updated to whatever the latest syntax is. Closing this now - cheers.

@nateraw nateraw closed this as completed Sep 13, 2022
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