Debug Notes

Some of the notes are collected from online resources. Please advise to remove immediately if any infringement caused. (lz2494@columbia.edu)

Cuda

  • Cuda driver version should be consistent with cuda runtime version
  • If the hardware already satisfied, we can use any lower version for the cuda toolkit.
  • Remove cuda
    • sudo apt-get autoremove –purge cuda
  • Version check
    • Cuda: $ cat /usr/local/cuda/version.txt
    • Cudnn: $ cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
  • Cuda driver version
    • run make in /usr/local/cuda/samples
    • ./bin/x86_64/linux/release/deviceQuery
  • Verify Cuda installation
    • cd ~/
      apt-get install cuda-samples-7-0 -y
      cd /usr/local/cuda-7.0/samples
      make
    • ./deviceQuery
  • Note: In general, the driver version should be greater than or equal to the runtime version.

GPU card

  • nvidia-smi
  • If nvidia-smi command not found
    • sudo apt purge nvidia-*
      sudo add-apt-repository ppa:graphics-drivers/ppa
      sudo apt update
      sudo apt install nvidia-384

Docker

  • docker search cuda8
  • docker pull allansp84/ubuntu16.04-cuda8.0-opencv3.2
  • Mount local drive and enable display within docker
    • nvidia-docker run –name [Container Name] -ti -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v [Local machine directory]:[Docker container directory] [Image Name]
  • Add device
    • nvidia-docker run –name [Container Name] -ti -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v [Local machine directory]:[Docker container directory] –device /dev/video0 [Image Name]
  • Enter a running docker
    • nvidia-docker exec -it [Container Name] bash
  • Start a stopped docker container
    • nvidia-docker start -ai [Container Name]
  • Exit a docker
    • Exit

Ubuntu:

  • Logout through terminal when display crashed.
    • xfce4-session-logout
    • xfdesktop &
  • Enable webcam if you cannot open it through opencv open.
    • Chmod 777 /dev/video0
  • Kill the CPU/GPU process
    • Ctrl+z
    • See GPU process
      • Nvidia-smi
    • See process of you
      • ps -u [username]
    • Kill -9 PID
    • Kill the process within a docker container
      • ps aux
    • apt-file
      • apt-file search [filename]
    • Find a file using command line
      • find ~/ -type f -name “[filename]”
    • Count how many files
      • ls -1 | wc -l
    • Write the terminal log into text file.
      • Python2 [pythonfile_name].py | tee /path/to/log/file.txt

Caffe

  • # These instructions are for bash
    $ echo $SHELL
    /bin/bash

    • # Check the current value of your envvar
      $ echo $CAFFE_ROOT
    • # Add the envvar to ~/.profile so it will load automatically when you login
      $ echo “export CAFFE_ROOT=/home/username/caffe/” >> ~/.profile
    • # Load the new configuration
      $ source ~/.profile
    • # Check the new envvar value
      $ echo $CAFFE_ROOT
      /home/username/caffe/
  • Build Caffe
    • failed to see hdf5.h
      • apt-get install libhdf5-dev
    • Need to change Makefile.config to set correct path of cuda.
    • so Undefined reference to jas_stream.xxxxx
      • in Makefile.config, uncomment USE_PKG_CONFIG:=1
    • Caffe installation guide
      • cp Makefile.config.example Makefile.config
        # Adjust Makefile.config (for example, if using Anaconda Python, or if cuDNN is desired)
        make all
        make test
        make runtest
      • Make pycaffe
      • export PYTHONPATH=~/caffe_train_new/caffe_train/python:$PYTHONPATH

Cmake-qt-gui

Git clone sub-directories

  • git clone –recurse-submodules

MATLAB:

  • Watch out:When write sub-functions inside a main function, check whether you have put the sub-function outside the main function file as a separate .m file or inside the main function file, check whether you have created both, which will lead your program enter wrong function. Spent some time today to find out there are actually two sub-functions…
  • Install MATLAB runtime within a docker container
    • wget http://ssd…..
    • mkdir temp
    • unzip xxx.zip -d temp
    • cd temp
    • ./install -mode silent -agreeToLicense yes
    • On the target computer, append the following to your LD_LIBRARY_PATH environment variable: /usr/local/MATLAB/MATLAB_Run
    • Run matlab via command line
  • Check MATLAB installation path
    • Open matlab, inside the command window
    • matlabroot

Binary file permission denied

  • chmod +x file
  • Chmod +x -R dir

Mac: Set python path

  • $PYTHONPATH=$PYTHONPATH:/xxx/xxx/xx

OpenCV

  • # install dependencies
    sudo apt-get update
    sudo apt-get install -y build-essential
    sudo apt-get install -y cmake
    sudo apt-get install -y libgtk2.0-dev
    sudo apt-get install -y pkg-config
    sudo apt-get install -y python-numpy python-dev
    sudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev
    sudo apt-get install -y libjpeg-dev libpng-dev libtiff-dev libjasper-devsudo apt-get -qq install libopencv-dev build-essential checkinstall cmake pkg-config yasm libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils# download opencv-2.4.11
    wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.11/opencv-2.4.11.zip
    unzip opencv-2.4.11.zip
    cd opencv-2.4.11
    mkdir release
    cd release

    # compile and install
    cmake -G “Unix Makefiles” -D CMAKE_CXX_COMPILER=/usr/bin/g++ CMAKE_C_COMPILER=/usr/bin/gcc -D CUDA_GENERATION=Auto -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D BUILD_FAT_JAVA_LIB=ON -D INSTALL_TO_MANGLED_PATHS=ON -D INSTALL_CREATE_DISTRIB=ON -D INSTALL_TESTS=ON -D ENABLE_FAST_MATH=ON -D WITH_IMAGEIO=ON -D BUILD_SHARED_LIBS=OFF -D WITH_GSTREAMER=ON ..
    make all -j4 # 4 cores
    sudo make install

# If you are using CUDA 8.0, edit graphcut.cpp (this file does not support CUDA 8.0)
# For more detail, please refer to https://rohanrajblogs.blogspot.kr/2016/12/installation-of-opencv-2411-along-with.html?m=0
# $ vim /home/<user name>/opencv-2.4.11/modules/gpu/src/graphcuts.cpp
# Now search for this specific line .
# if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)
# Replace the line with this line .
# if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) || (CUDART_VERSION >= 8000)

# ignore libdc1394 error http://stackoverflow.com/questions/12689304/ctypes-error-libdc1394-error-failed-to-initialize-libdc1394

#python
#> import cv2
#> cv2.SIFT
#<built-in function SIFT>

Cmake not find QT5

  • apt install qtbase5-dev

Problems with gflag.h glog

  • apt-get install libgflags-dev
  • apt-get install libgoogle-glog-dev

Hdf5.h not found

  • — +INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include

— +LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib

++ +INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/

++ +LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial/

Convert COCO dataset format to Pascal format