drupal_render() is deprecated. What replaces it?
It was replaced with the renderer service. 

$render_service = \Drupal::service('renderer');


As mpdonadio and 4k4 have pointed out in the comments, to prevent metadata from bubbling up to the main request, you should execute this in a new render context. You can do so by using the renderPlain method, rather than the usual render method (unless you're returning this from a controller, in which case use renderRoot instead).

$rendered = $render_service-&gt;renderPlain($build);