CVX return NaN in most runs,and sometimes it works

Follow the instructions to use CVXQUAD CVXQUAD: How to use CVXQUAD's Pade Approximant instead of CVX's unreliable Successive Approximation for GP mode, log, exp, entr, rel_entr, kl_div, log_det, det_rootn, exponential cone. CVXQUAD's Quantum (Matrix) Entropy & Matrix Log related functions

I can not try to solve your problem because you have not provided all the inputs to make it reproducible. Please let us know what happens when you use CVXQUAD.