CUDA lib not working after suspend on Ubuntu 16.04

Just for the record for the other people having the same problem I created following file:

-rwxr-xr-x 1 root root 162 cze 9 21:16 nvidia-reload

File /etc/pm/sleep.d/nvidia-reload:

#! /bin/sh
# Workaround for not working nvidia cuda after suspend
case $1 in
    resume|thaw)
	sudo rmmod nvidia_uvm
	sudo modprobe nvidia_uvm
    ;;
esac

Now this is called every time computer is booted from suspend.