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.
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.