In fact, your given code has no problem of model initialization and moving the model to GPU for me. I found your error included in this post.

  
      
      Medium – 14 Nov 19
  
  
    

CUDA error: Device-side assert triggered 203

A beginner friendly solution walkthrough for this frustrating (and common) error in Pytorch

  Reading time: 5 min read