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

[Bug]: Inconsistent Use of CUDA Devices When Using GPU with notears #213

Open
1 task done
blacksnail789521 opened this issue Sep 14, 2023 · 0 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@blacksnail789521
Copy link

Contact Details

[email protected]

Short description of the problem here.

When using GPU support via from causalnex.structure.pytorch.notears import from_pandas, an error occurs due to some nn.Module components not residing on CUDA devices. The problematic code is:

x = nn.LayerNorm(
    output_dim,
    eps=self.nonlinear_clamp,
    elementwise_affine=True,
)(x)

Link to the code.

To reproduce the error, set hidden_layer_units to [5].

A potential fix might be to append .to(self.device) after LayerNorm, like this:

x = nn.LayerNorm(
    output_dim,
    eps=self.nonlinear_clamp,
    elementwise_affine=True,
).to(self.device)(x)

CausalNex Version

0.12.1

Python Version

3.10.12

Relevant code snippet

x = nn.LayerNorm(
                output_dim,
                eps=self.nonlinear_clamp,
                elementwise_affine=True,
            )(x)

Relevant log output

RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! (when checking argument for argument weight in method wrapper_CUDA__native_layer_norm)

Code of Conduct

  • I agree to follow this project's Code of Conduct
@blacksnail789521 blacksnail789521 added the bug Something isn't working label Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant