We demonstrated optical-controlled graphene-based nonvolatile transistors incorporated with azobenzene copolymer. The transistor was gated by the quasi remnant polarization of azobenzene copolymer, which was built by photo-assisted poling and erased by photo-depoling at room temperature. By taking the nature of polymer electret of azobenzene copolymer, the graphene-based device can perform ternary logic, and the resistance change ratio of the written status "±1" to the erased status "0" was ?60%. The device can retain its statuses against an electric field as high as 0.2 MV/cm because the azobenzene molecules were frozen in copolymer at room temperature. ? 2013 American Institute of Physics.