Among various satellite actuators, magnetic torquers have been widely equipped for stabilization and attitude control of small satellites. Although magnetorquers are generally used with other actuators, such as momentum wheels, this paper explores a control method where only a magnetic actuation is available. We applied a nonlinear optimal control method, Nonlinear Model Predictive Control (NMPC), to small satellites, employing the generalized minimal residual (GMRES) method, which generates continuous control inputs. Onboard magnetic actuation systems often find it challenging to produce smooth magnetic moments as a control input; hence, we employ Pulse Width Modulation (PWM) method, which discretizes a control input and reduces the burden on actuators. In our case, the PWM approach discretizes control torques generated by the NMPC scheme. This study’s main contributions are investigating the NMPC and the GMRES method applied to small spacecraft and presenting the PWM control system’s feasibility.