Installing OpenCV3.4 on Ubuntu 18.04 ML in a Box Public Template


I am trying to run the code given in To do this, I am installing all the dependencies first given in I am unable to install opencv3.4 version properly.
When I try to make -j8, I get this issue:

/usr/bin/ranlib ../../lib/libopencv_perf_cudafeatures2d_pch_dephelp.a
make[2]: Leaving directory '/home/paperspace/opencv-3.4.0/build'
[ 13%] Built target opencv_perf_cudafeatures2d_pch_dephelp
make[1]: Leaving directory '/home/paperspace/opencv-3.4.0/build'
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2```

I tried to install OpenCV using but the error remains the same.

What can be the possible issue for this and how can I install OpenCV 3.4 on this machine?