> Would I be able to retain the intellectual property of my software?
If your research received funding from a government agency such as NSF, they might have a claim to your IP.
If you're funded by the university as a teaching or research assistant, there would be an employer/employee relationship, and your work could be owned by the university under a "work for hire" contract clause.
> Would I be able to commercialize it?
If someone other than you owned the IP, you'd need their permission to commercialize it (they might want a big chunk of the company, or they may refuse and contract with someone else to commercialize it).
If you really care about this, you should talk to a lawyer (who specializes in IP) before doing anything that might jeopardize your plans. They might advise you to do a PhD on a different but related topic and not start developing the software until you left the university.
Also, different universities may have different policies on IP ownership/licensing. Some may be more startup-friendly than others.