Preheat the oven to 3500F (1750C). Grease two 9-inch round cake pans and set aside.
In a medium bowl, whisk together the flour, baking powder, baking soda, cinnamon, ginger, nutmeg, and salt.
In a large bowl, whisk together the sugar and oil until well combined. Add the eggs one at a time, whisking well after each addition.
Add the dry ingredients to the wet ingredients and stir until just combined. Fold in the grated carrots and chopped walnuts (if using).
Divide the batter evenly between the prepared cake pans and smooth out the tops.
Bake for 35-40 minutes or until a toothpick inserted into the center of the cake comes out clean.
Remove the cakes from the oven and let them cool in the pans for 10 minutes before transferring them to a wire rack to cool completely.
While the cakes are cooling, make the cream cheese frosting. In a large bowl, beat the cream cheese and butter together until smooth and creamy. Add the powdered sugar and vanilla extract and beat until the frosting is smooth and fluffy.
Once the cakes have cooled, place one cake layer on a cake stand or plate. Spread a thick layer of frosting on top, then place the second cake layer on top. Spread the remaining frosting on top and around the sides of the cake.
Slice and serve the carrot cake immediately or store it in the refrigerator for up to 4 days.