<?php echo get_avatar( get_the_author_meta( 'ID') , 150); ?>
Is exactly what I use.
I think the issue is with “foreach( $recent_posts as $recent )”, I recommend using
if ( $wp_query->have_posts() ) :
I recommend checking out https://developer.wordpress.org/reference/classes/wp_query/ and remember to reset the loop with after your done
wp_reset_postdata();