Preheat your oven to 350°F (175°C). Grease and flour your baking pan(s) or line them with parchment paper to prevent sticking.
In a large bowl, whisk together 2 cups all-purpose flour, 2 cups granulated sugar, 1 teaspoon baking powder, 1 teaspoon baking soda, 1/2 teaspoon salt, 1 teaspoon ground cinnamon, and 1/2 teaspoon ground nutmeg until well combined.
In another bowl, whisk together 1 cup vegetable oil and 4 large eggs until smooth. Stir in the grated carrots and the drained 1 cup crushed pineapple.
Slowly add the dry ingredients to the wet mixture, folding gently with a spatula until just combined. Be careful not to overmix; the batter should be thick but smooth. If using, fold in 1 cup chopped walnuts at this point.
Pour the batter into your prepared pan(s) and smooth the top. Bake for 40-50 minutes, or until a toothpick inserted into the center comes out clean. Baking times may vary slightly depending on your oven and pan size.
Allow the cake to cool in the pan for about 15 minutes, then transfer it to a cooling rack to cool completely before frosting.
In a bowl, beat together 8 oz softened cream cheese and 1/2 cup softened unsalted butter until smooth and creamy. Gradually add 4 cups powdered sugar, beating well after each addition. Stir in 1 teaspoon vanilla extract. Adjust the consistency by adding more powdered sugar if needed.
Once the cake is completely cool, generously spread the cream cheese frosting over the top (and sides if using round layers). For a decorative touch, use a spatula or piping bag.