Environment: Ubuntu 16.04, CUDA 10
The trickiest part is, OpenCV 4 only supports CUDA 10, not CUDA 10.1. So if you have installed CUDA 10.1, you have to get 10.0 instead.
sudo apt-get install gcc gfortran python-dev libopenblas-dev liblapack-dev cython
sudo apt-get install build-essential