Now I got this error:
RuntimeError: CUDA out of memory. Tried to allocate 588.00 MiB (GPU 0; 4.00 GiB total capacity; 2.95 GiB already allocated; 150.76 MiB free; 2.97 GiB reserved in total by PyTorch)
and optimizer.step() generate the error.