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

Textattack for cuml models not utilising much GPU resources #790

Open
farwashah6 opened this issue May 13, 2024 · 0 comments
Open

Textattack for cuml models not utilising much GPU resources #790

farwashah6 opened this issue May 13, 2024 · 0 comments

Comments

@farwashah6
Copy link

Hi. I am new to using GPU. I have used the Textattack library earlier for one of my projects using Sklearn and Keras models. For that I created the customModelWrappers according to my models and they worked fine. Now since my data is different and very big, I want to implement it using GPU for the same (sklearn) models.

I have the understanding that sklearn models do not implement on GPU and I have to use CUML instead. But when I use CUML, and pass the cuml model to the CustomModelWrapper I created earlier, it gives me the following error
len() of unsized object
and then stops the execution.

Additional Info: For vectorisation of my data I am using CountVectorizer of cuml, which is the cause of this error. Instead when I use CountVectorizer of sklearn it does the attack but doesn't use much GPU resources (of course). Please help me in this.

I am attaching my modelWrapper here.

class CustomModelWrapper(ta.models.wrappers.ModelWrapper):

    def __init__(self, model, vectorizer):
        super().__init__()
        self.model = model
        self.vectorizer = vectorizer

    def __call__(self, text_input_list, batch=None):
        x_transform = self.vectorizer.transform(pd.Series(text_input_list)).astype(float)
        prediction = self.model.predict_proba(x_transform)
        return prediction
@farwashah6 farwashah6 changed the title Textattack fro cuml models not utilising much GPU resources Textattack for cuml models not utilising much GPU resources May 13, 2024
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