Fix optimization error
Merge pull request #2006 from nouiz/opt_err_gpua

Fix optimization error