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

sat-12l-sm running on GPU #120

Closed
Randwow opened this issue Jul 2, 2024 · 6 comments
Closed

sat-12l-sm running on GPU #120

Randwow opened this issue Jul 2, 2024 · 6 comments
Assignees

Comments

@Randwow
Copy link

Randwow commented Jul 2, 2024

Hi @bminixhofer,

I'm trying to use sat-12l-sm on GPU with the following code:

MODEL_NAME = "sat-12l-sm"
sat = SaT(MODEL_NAME)
sat.to("cuda")

However, when I run nvidia-smi in the terminal, it doesn't show any usage of the GPU, and it seems that the GPU is not being utilized. Could you please provide any guidance or suggestions on how to ensure that the model is actually using the GPU?

Thank you!

@markus583
Copy link
Collaborator

Hi, this is a bit odd, and should not be the case. Is your torch properly set up? Did you check with nvidia-smi also after calling sat.split("some text")?
I just tried it myself and it works as intended. The time needed is also much lower after doing sat.cuda(). I suggest you compare time needed to segment some sentences on CPU and GPU; the latter should be an order of magnitude faster.

@markus583 markus583 self-assigned this Jul 3, 2024
@Randwow
Copy link
Author

Randwow commented Jul 3, 2024

Hi, yes I will check thank you )

@lifeiteng
Copy link

Hi, this is a bit odd, and should not be the case. Is your torch properly set up? Did you check with nvidia-smi also after calling sat.split("some text")? I just tried it myself and it works as intended. The time needed is also much lower after doing sat.cuda(). I suggest you compare time needed to segment some sentences on CPU and GPU; the latter should be an order of magnitude faster.

can we set cuda index?

@markus583
Copy link
Collaborator

Hi, this is a bit odd, and should not be the case. Is your torch properly set up? Did you check with nvidia-smi also after calling sat.split("some text")? I just tried it myself and it works as intended. The time needed is also much lower after doing sat.cuda(). I suggest you compare time needed to segment some sentences on CPU and GPU; the latter should be an order of magnitude faster.

can we set cuda index?

Should be possible, yes. It is no different than other PyTorch models in this regard.

@lifeiteng
Copy link

There is a bug in class PyTorchWrapper

sat = SaT("sat-3l")

# this is not right
sat = sat.to(device)

# I used this
_ = sat.model.model.to(device)

# source code
class PyTorchWrapper:
    def __init__(self, model):
        self.model = model
        self.config = model.config

    def __getattr__(self, name):
        assert hasattr(self, "model")
        return getattr(self.model, name)

@markus583
Copy link
Collaborator

Why is this a bug? I have been using sat = sat.to("cuda") and it worked just fine. Is it any different if you use, e.g., "cuda:2"?

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

3 participants