If you are a
nonresident alien for any part of the year, you generally cannot claim any education credits or deductions. However, you
may be able to claim an education credit under the following circumstances.
1. You are married and
choose to file a joint return with a U.S. citizen or resident spouse as
discussed under
Nonresident Spouse Treated as a
Resident in Publication 519 chapter 1.
2. You are a dual-status
alien, and choose to be treated as a U.S. resident for the entire year.
See
Choosing Resident Alien Status in Publication 519 chapter 1.
See attached screenshot.