Skip to content

Problem when moving to mps device #3

@ndwork

Description

@ndwork

When I attempted to use my Macbook's GPU, the code crashed. It came down to the following line in Part 3:
self.pe = pe.unsqueeze(0)

I found that I could fix it by changing that line to the following:
self.register_buffer( 'pe', pe.unsqueeze(0) )

By using register_buffer, pytorch knows to move pe to the specified device along with the model.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions