Given a 2D array in Python, write a code to calculate the sum of all elements.
arr = [[1, 2, 3], [4, 5, 6], [7 , 8, 9]]
total = 0
for row in arr: 
    for num in row: 
        total += num 
print(total) # 45