Skip to content

Instantly share code, notes, and snippets.

@bala-codes
Created October 24, 2020 04:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bala-codes/a3d5d79d3066ed39dfb6eabc587cdd7b to your computer and use it in GitHub Desktop.
Save bala-codes/a3d5d79d3066ed39dfb6eabc587cdd7b to your computer and use it in GitHub Desktop.
OpenCV + CUDA + (No Tears)
1 05/10/20 17:40:44 clear
2 05/10/20 17:40:44 sudo apt-get update
3 05/10/20 17:40:44 sudo apt-get upgrade
4 05/10/20 17:40:44 sudo apt-get install build-essential cmake unzip pkg-config
5 05/10/20 17:40:44 sudo apt-get install gcc-6 g++-6
6 05/10/20 17:40:44 sudo apt-get install screen
7 05/10/20 17:40:44 sudo apt-get install libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev
8 05/10/20 17:40:44 sudo apt-get install libjpeg-dev libpng-dev libtiff-dev
9 05/10/20 17:40:44 sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
10 05/10/20 17:40:44 sudo apt-get install libxvidcore-dev libx264-dev
11 05/10/20 17:40:44 sudo apt-get install libopenblas-dev libatlas-base-dev liblapack-dev gfortran
12 05/10/20 17:40:44 sudo apt-get install libhdf5-serial-dev
13 05/10/20 17:40:44 sudo apt-get install python3-dev python3-tk python-imaging-tk
14 05/10/20 17:40:44 sudo apt-get install libgtk-3-dev
15 05/10/20 17:40:44 sudo add-apt-repository ppa:graphics-drivers/ppa
16 05/10/20 17:40:44 sudo apt-get update
17 05/10/20 17:40:44 sudo apt-get install nvidia-driver-418
18 05/10/20 17:40:44 sudo reboot
19 05/10/20 17:40:47 clear
20 05/10/20 17:40:51 nvidia-smi
21 05/10/20 17:40:58 clear
22 05/10/20 17:41:09 mkdir installers
23 05/10/20 17:41:14 cd installers/
24 05/10/20 17:41:27 wget https://developer.nvidia.com/compute/cuda/10.0/Prod/local_installers/cuda_10.0.130_410.48_linux
25 05/10/20 17:43:30 mv cuda_10.0.130_410.48_linux cuda_10.0.130_410.48_linux.run
26 05/10/20 17:43:36 chmod +x cuda_10.0.130_410.48_linux.run
27 05/10/20 17:43:42 sudo ./cuda_10.0.130_410.48_linux.run --override
28 05/10/20 17:48:31 clear
29 05/10/20 17:48:44 sudo vim ~/.bashrc
30 05/10/20 17:49:18 source ~/.bashrc
32 05/10/20 17:49:32 nvcc -V
33 05/10/20 17:50:01 sudo apt-get update
34 05/10/20 17:50:07 sudo apt-get upgrade
35 05/10/20 17:50:17 sudo apt-get install build-essential cmake unzip pkg-config
36 05/10/20 17:50:27 sudo apt-get install libjpeg-dev libpng-dev libtiff-dev
37 05/10/20 17:50:34 sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev
38 05/10/20 17:50:42 sudo apt-get install libgtk-3-dev
39 05/10/20 17:50:49 cd ~
40 05/10/20 17:51:09 wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/4.2.0.zip
40 05/10/20 17:51:09 wget -O opencv.zip https://github.com/opencv/opencv/archive/4.2.0.zip
41 05/10/20 17:51:18 unzip opencv.zip
42 05/10/20 17:51:26 unzip opencv_contrib.zip
43 05/10/20 17:51:31 mv opencv-4.2.0 opencv
44 05/10/20 17:51:36 mv opencv_contrib-4.2.0 opencv_contrib
45 05/10/20 17:52:07 wget https://bootstrap.pypa.io/get-pip.py
46 05/10/20 17:52:18 sudo python3 get-pip.py
47 05/10/20 17:53:15 sudo pip install virtualenv virtualenvwrapper
48 05/10/20 17:53:27 sudo rm -rf ~/get-pip.py ~/.cache/pip
49 05/10/20 17:53:43 clear
50 05/10/20 17:54:10 sudo vim ~/.bashrc
52 05/10/20 17:54:43 source ~/.bashrc
53 05/10/20 17:55:05 mkvirtualenv opencv_cuda -p python3
54 05/10/20 17:55:11 clear
55 05/10/20 17:55:18 pip install numpy
56 05/10/20 17:55:31 nvidia-smi
57 05/10/20 17:55:55 cd ~/opencv
58 05/10/20 17:55:59 mkdir build
59 05/10/20 17:56:02 cd build
60 05/10/20 17:56:04 clear
61 05/10/20 17:57:08 cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=OFF -D OPENCV_ENABLE_NONFREE=ON -D WITH_CUDA=ON -D WITH_CUDNN=OFF -D OPENCV_DNN_CUDA=ON -D ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 -D CUDA_ARCH_BIN=7.0 -D WITH_CUBLAS=1 -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules -D HAVE_opencv_python3=ON -D PYTHON_EXECUTABLE=~/.virtualenvs/opencv_cuda/bin/python -D BUILD_EXAMPLES=ON ..
62 05/10/20 17:59:53 make -j$(nproc)
63 05/10/20 18:52:45 sudo make install
64 05/10/20 18:56:41 sudo ldconfig
65 05/10/20 18:58:06 clear
66 05/10/20 18:58:09 ls -l /usr/local/lib/python3.6/site-packages/cv2/python-3.6
67 05/10/20 18:59:02 cd ~/.virtualenvs/opencv_cuda/lib/python3.6/site-packages/
68 05/10/20 18:59:56 ln -s /usr/local/lib/python3.6/site-packages/cv2/python-3.6/cv2.cpython-36m-x86_64-linux-gnu.so cv2.so
69 05/10/20 19:00:11 python
70 05/10/20 19:01:52 cd
@mahfuz-raihan
Copy link

mahfuz-raihan commented Jan 1, 2022

sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev is not working on my local pc and I'm using ubuntu 20.04(LTE). (I installed gcc-9 and g++-9)
how to get rid from this? any solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment