Preheat oven to 350°F (175°C). Grease and flour two 8-inch round cake pans. Line the bottoms with parchment paper.
Whisk dry ingredients: In a large bowl, whisk together flour, baking powder, baking soda, salt, and spices.
Cream wet ingredients: In another bowl, cream together sugars and oil until light and fluffy. Beat in eggs one at a time, then stir in vanilla extract.
Combine wet and dry: Add the wet ingredients to the dry ingredients in three additions, alternating with the grated carrots. Mix until just combined, do not overmix.
Fold in nuts (optional): Gently fold in chopped walnuts or pecans, if using.
Bake: Divide batter evenly between prepared cake pans. Bake for 35-40 minutes, or until a toothpick inserted into the center comes out clean.
Cool cakes: Let cakes cool in pans for 10 minutes, then transfer to wire racks to cool completely.
Make frosting: While cakes cool, cream together cream cheese and butter until light and fluffy. Gradually add powdered sugar, beating until smooth. Stir in vanilla extract and salt.
Frost cake: Once cakes are cool, spread a generous layer of frosting over one cake layer. Top with the second cake layer and frost the top and sides.