One thing I know about CPS is that if you crank the car and the tachometer doesn't move, that's a good indicator of CPS failure. Usually the DIC starts to fail by first throwing codes P1312, P1334, P0340 (and possibly others). CPS does not usually throw any codes.My '06 did the same thing last year and I replaced the CPS. Didnt fix it. Next was a new DIC and that did the trick. I dont know of a way to diagnose either effectively. I started with the CPS because it was less expensive. Both of them are items that just require periodic replacement anyway. So now I don't have to worry about either for quite a while.
Maybe someone else will have more advise on how to diagnose which one it could be. Like Nocturne says above - maybe a CPS issue needs to be cold to start at all and wont stay running?
My car ran good but if I stopped somewhere, I'd have to wait for the car to cool off before it word start again. Again, my issue was the DIC.