Friday 29 January 2021

How to install nvidia driver and cuda together in ubuntu18?

1. boot into ubuntu os

2. login to os and download cuda installer, cuda_10.2.89_440.33.01_linux.run (the best version for 2080ti)

3. press ctrl + alt + f3

4. login with username and password

5. type the following commands in terminal:-

sudo service gdm stop

sudo apt purge nvidia*

sudo apt install gcc

sudo apt install libglvnd-dev

sudo sh  cuda_10.2.89_440.33.01_linux.run (check all boxes and install) 

Once completed, you should able to see driver, toolkit and samples installed successfully. Then,

sudo reboot

nvidia-smi

Tuesday 26 January 2021

How to add cmake arguments in vscode?

 Ctrl + Shift + P -> Open Workspace Settings (Json)

{
    "cmake.configureArgs": [
        "-DCMAKE_INSTALL_PREFIX=/home/ninja/workspace/opencv/distribute",
        "-DWITH_CUDA=ON",
        "-DWITH_CUBLAS=ON",
        "-Dpkgcfg_lib_FFMPEG_avformat=/usr/local/ffmpeg/lib/libavformat.so",
        "-Dpkgcfg_lib_FFMPEG_avcodec=/usr/local/ffmpeg/lib/libavcodec.so",
        "-Dpkgcfg_lib_FFMPEG_avutil=/usr/local/ffmpeg/lib/libavutil.so",
        "-DOPENCV_EXTRA_MODULES_PATH=/home/ninja/workspace/opencv_contrib-4.2.0/modules",
    ]
}



==========================================

Opencv4.4.0 with CUDA, NVCUVID

==========================================

{
    "cmake.configureArgs": [
        "-DCMAKE_BUILD_TYPE=RELEASE",
        "-DCMAKE_INSTALL_PREFIX=/home/ninja/workspace/opencv-4.4.0/distribute",
        "-DINSTALL_C_EXAMPLES=ON",
        "-DOPENCV_GENERATE_PKGCONFIG=ON",
        "-DINSTALL_PYTHON_EXAMPLES=ON",
        "-DBUILD_SHARED_LIBS=ON",
        "-DWITH_TBB=ON",
        "-DWITH_V4L=ON",
        "-DBUILD_opencv_world=OFF",
        "-DOPENCV_PYTHON3_INSTALL_PATH=/home/ninja/workspace/opencv-4.4.0/distribute/python3",
        "-DWITH_QT=ON",
        "-DWITH_OPENGL=ON",
        "-DWITH_CUDA=ON",
        "-DWITH_CUFFT=ON",
        "-DWITH_CUBLAS=ON",
        "-DWITH_NVCUVID=ON",
        "-DBUILD_CUDA_STUBS=ON",
        "-DBUILD_opencv_cudalegacy=ON",
        "-DBUILD_opencv_cudacodec=ON",
        "-DCUDA_FAST_MATH=ON",
        "-DCUDA_GENERATION=Kepler",
        "-DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-10.2",
        "-DCUDA_nvcuvid_LIBRARIES=/home/ninja/workspace/Video_Codec_SDK_10.0.26/Lib/linux/stubs/x86_64/libnvcuvid.so",
        "-DCUDA_nvcuvenc_LIBRARIES=/home/ninja/workspace/Video_Codec_SDK_10.0.26/Lib/linux/stubs/x86_64/libnvidia-encode.so",
        "-DOPENCV_EXTRA_MODULES_PATH=/home/ninja/workspace/opencv_contrib-4.4.0/modules",
        "-DBUILD_NEW_PYTHON_SUPPORT=ON",
        "-DBUILD_opencv_python3=ON",
        "-DHAVE_opencv_python3=ON",
        "-DPYTHON3_EXECUTABLE=/home/ninja/anaconda3/bin/python",
        "-DPYTHON3_DEFAULT_EXECUTABLE=/home/ninja/anaconda3/bin/python",
        "-DPYTHON3_INCLUDE_PATH=/home/ninja/anaconda3/include/python3.8",
        "-DPYTHON3_NUMPY_INCLUDE_DIRS=/home/ninja/anaconda3/lib/python3.8/site-packages/numpy/core/include",
        "-DPYTHON3_PACKAGES_PATH=/home/ninja/anaconda3/lib/python3.8/site-packages",
        "-DPYTHON3_LIBRARIES=/home/ninja/anaconda3/lib/libpython3.8.so",
        "-DPYTHON3_LIBRARIES_PATH=/home/ninja/anaconda3/lib",
        "-DBUILD_EXAMPLES=ON"
        ]
}


(put include_directories(/home/ninja/workspace/Video_Codec_SDK_10.0.26/Interface) into CMakeLists.txt)

Wednesday 20 January 2021

How to remove .jpg files in current and subfolders?

current folder and one level sub folder:-

find . -maxdepth 2 -type f -name "*.jpg" -delete 

or

find . -name "*.jpg" -exec rm -rf {} \;



Tuesday 19 January 2021

How to install labelme in ubuntu using python2.7?

 conda create -n labelme python=2.7

conda activate labelme

conda install pyqt

pip install labelme

How to install different ubuntu desktop?

Kubuntu: apt-get install kubuntu-desktop (KDE)
Xubuntu: apt-get install xubuntu-desktop (XFCE) - like windows
Lubuntu: apt-get install lubuntu-desktop (LXDE)
Ubuntu GNOME: apt-get install ubuntu-gnome-desktop (Gnome)

Sunday 17 January 2021

How to kill a process based on process name?

 kill -9 $(pidof watch) 

# where 'watch' is the process name

Saturday 16 January 2021

how to get opencv build information?

 print(cv2.getBuildInformation())

 

cout << cv.getBuildInformation() << endl;

Tuesday 12 January 2021

How to convert H264 to MP4 using x264 in ubuntu?


sudo apt-get install x264 

x264 raw_stream.264 -o playable_video.mp4

x264 raw_stream.264 -o playable_video.mp4 --opencl (with gpu?)

 

Monday 11 January 2021