I can't comment due to lack of reputation, so I'll address the issue rudtek mentioned. Personally, I never came across a host that disables PHP's rand() function, but in case there is such a lousy host, you can opt for a more efficient way of doing things. What you can do is to get all the image ids, and select a random id from the available list. This way you greatly reduce the memory footprint and cpu usage. See the code sample below
// get all image ids available
$image_ids = get_posts(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_status' => 'inherit',
'posts_per_page' => -1,
'fields' => 'ids',
// based on the number of image_ids retrieved, generate a random number within bounds.
$num_of_images = count($image_ids);
$random_index = rand(0, $num_of_images);
$random_image_id = $image_ids[$random_index];
// now that we have a random_image_id, lets fetch the image itself.
$image = get_post($random_image_id);
// you can do whatever you want with $image now.
The code above shouldn't have any issues, but you will have to work on it further if you wish to display the random image chosen. If you don't have to necessary programming skill to get it working, I might try to write out a low-footprint solution sometime soon.
Alternatively, there should be plugins available to do what you want, just that they may indeed be quite bloated. Also note that performance might be heavily affected if you have thousands or more images in your library.