Wednesday, July 26, 2017

How to set up priorities for installing package using apt-get


References

Example

  •  In the following setup officially nvidia-provided driver is to be installed.
$ vim /etc/apt/preferences.d/cuda
Package: *
Pin: origin "developer.download.nvidia.com"
Pin-Priority: 1000
  •  Check status using `apt-cache policy`
$ sudo apt-cache policy nvidia-375*
nvidia-375-dev:
  Installed: 375.51-0ubuntu1
  Candidate: 375.51-0ubuntu1
  Version table:
     375.82-0ubuntu0~gpu16.04.1 500
        500 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu xenial/main amd64 Packages
     375.66-0ubuntu0.16.04.1 500
        500 http://kr.archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages
        500 http://security.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages
 *** 375.51-0ubuntu1 1000
       1000 http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64  Packages
        100 /var/lib/dpkg/status
     375.26-0ubuntu1 1000
       1000 http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64  Packages
nvidia-375:
  Installed: 375.51-0ubuntu1
  Candidate: 375.51-0ubuntu1
  Version table:
     375.82-0ubuntu0~gpu16.04.1 500
        500 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu xenial/main amd64 Packages
     375.66-0ubuntu0.16.04.1 500
        500 http://kr.archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages
        500 http://security.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages
 *** 375.51-0ubuntu1 1000
       1000 http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64  Packages
        100 /var/lib/dpkg/status
     375.26-0ubuntu1 1000
       1000 http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64  Packages












Android Face Detection

Neven Vision

Android Camera1 FaceDetection

 

 

Analysis

 

Building OpenCV from Source


Prerequisites

sudo apt-get -y update
sudo apt-get -y upgrade

echo "Installing build tools"
sudo apt-get -y install build-essential cmake pkg-config

echo "Installing GUI libraries and OpenGL extensions"
if [ $WITH_QT -ne 0 ]; then
  sudo apt-get -y install libqt4-dev
  sudo apt-get -y install libqt4-opengl-dev
else
  sudo apt-get -y install libgtk2.0-dev
  sudo apt-get -y install libgtkglext1 libgtkglext1-dev
fi

echo "Installing Python libraries"
sudo apt-get -y install python-dev python-numpy
sudo apt-get -y install python-scipy

echo "Installing media I/O libraries"
sudo apt-get -y install libpng12-0 libpng12-dev libpng++-dev libpng3
sudo apt-get -y install libpnglite-dev libpngwriter0-dev libpngwriter0c2
sudo apt-get -y install zlib1g zlib1g-dbg zlib1g-dev
sudo apt-get -y install pngtools
sudo apt-get -y install libjasper1 libjasper-dev libjasper-runtime
sudo apt-get -y install libjpeg8 libjpeg8-dbg libjpeg8-dev libjpeg-progs
sudo apt-get -y install libtiff4-dev libtiff4 libtiffxx0c2 libtiff-tools
sudo apt-get -y install openexr libopenexr-dev libopenexr6

echo "Installing video I/O libraries"
sudo apt-get -y install libavcodec53 libavcodec-dev libavformat53 libavformat-dev libavutil51 libavutil-dev
sudo apt-get -y install libswscale2 libswscale-dev
sudo apt-get -y install libgstreamer0.10-0-dbg libgstreamer0.10-0 libgstreamer0.10-dev
sudo apt-get -y install libxine1-ffmpeg libxine-dev libxine1-bin
sudo apt-get -y install libunicap2 libunicap2-dev
sudo apt-get -y install libdc1394-22 libdc1394-22-dev libdc1394-utils

echo "Installing codecs"
sudo apt-get -y install libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev
sudo apt-get -y install ffmpeg x264 libx264-dev libv4l-0 libv4l v4l-utils

echo "Installing multiprocessing libraries"
sudo apt-get -y install libtbb-dev


 diffstat docutils-common libavcodec-dev libavformat-dev libavutil-dev libblas-dev libdc1394-22-dev libilmbase-dev libjasper-dev libjpeg-dev libjpeg-turbo8-dev libjpeg8-dev libjs-sphinxdoc liblapack-dev
  libopenexr-dev libraw1394-dev libswscale-dev libtiff4-dev libtiffxx0c2 libv4l-dev python-docutils python-jinja2 python-roman python-sphinx python-support quilt sphinx-common swig swig2.0
  texlive-fonts-extra texlive-fonts-recommended
 


Build Documents

you should install
texlive, texlive-latex-extra, texlive-fonts-extra texlive-fonts-recommended
python-sphinx
dvipng
for building documents. These are for mathematical expression using Latex and .rst file manipulation

Android Development and Debugging Tips

Removing Whitespace

Options in Eclipse for fixing Whitespace errors  automatically
Automatic whitespace removing before git commit

Kernel Log message


We can get last log after rebooting without rooting
cat /proc/last_kmsg

After updating boot.img for eng mode, we can use "cat /proc/kmsg.


Sunday, September 13, 2015

OpenCL on Ubuntu 14.04 + Intel/Nvidia Dual Graphic Card for Heterogeneous Computing

Install

Nowadays many laptops have dual graphic cards, one Intel Integrated GPU for general computing as web surfing or simple works and one Nvidia GPU for gaming. Windows already support handling this dual graphic card system dynamically. Linux also support it. As I thought, How Linux supports it is a little different from Windows'. To use this feature users have to install "nvidia-prime" library by apt-get". It means that users use nvidia-made-something instead of a os-supported feature.

The following list shows my installed nvidia-libraries.
nvidia-prime is for handling dual graphic cards on my laptop.
It is very easy to miss to installing "nvidia-modprobe". It is why I wrote "nvidia-modprobe" in red.
$ dpkg -l |  grep nvidia
ii  nvidia-340                                            340.76-0ubuntu0.1                                   amd64        NVIDIA binary driver - version 340.76
ii  nvidia-340-dev                                        340.76-0ubuntu0.1                                   amd64        NVIDIA binary Xorg driver development files
ii  nvidia-340-uvm                                        340.76-0ubuntu0.1                                   amd64        Transitional package for nvidia-340
ii  nvidia-libopencl1-331                                 340.76-0ubuntu0.1                                   amd64        Transitional package for nvidia-libopencl1-340
ii  nvidia-libopencl1-340                                 340.76-0ubuntu0.1                                   amd64        NVIDIA OpenCL Driver and ICD Loader library
ii  nvidia-modprobe                                       340.24-1~ubuntu14.04.1                              amd64        utility to load NVIDIA kernel modules and create device nodes
ii  nvidia-opencl-dev:amd64                               5.5.22-3ubuntu1                                     amd64        NVIDIA OpenCL development files
ii  nvidia-opencl-icd-340                                 340.76-0ubuntu0.1                                   amd64        NVIDIA OpenCL ICD
ii  nvidia-prime                                          0.6.2                                               amd64        Tools to enable NVIDIA's Prime
ii  nvidia-settings                                       331.20-0ubuntu8                                     amd64        Tool for configuring the NVIDIA graphics driver

 Verification

We can verify it using clinfo. Unfortunately something is wrong when I run clinfo right after "apt-get install clinfo". So I downloaded clinfo's source by apt-get source clinfo and built it by myself.

 $ ./clinfo
Number of platforms                               1
  Platform Name                                   NVIDIA CUDA
  Platform Vendor                                 NVIDIA Corporation
  Platform Version                                OpenCL 1.1 CUDA 6.5.45
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_byte_addressable_store cl_khr_icd cl_khr_gl_sharing cl_nv_compiler_options cl_nv_device_attribute_query cl_nv_pragma_unroll cl_nv_copy_opts
  Platform Extensions function suffix             NV

  Platform Name                                   NVIDIA CUDA
Number of devices                                 1
  Device Name                                     GeForce GTX 765M
  Device Vendor                                   NVIDIA Corporation
  Device Vendor ID                                0x10de
                                             ...

Install Intel OpenCL for Heterogeneous Computing with Intel CPU + Nvidia GPU

Intel Providing 2 type of OpenCL. One is for CPU, the other is for Intel Integrated GPU. In this case I will setup only Intel OpenCL for Intel CPU.
If you search on Google using related keywords such as "intel opencl", you can find easily this kind of pages.

I use Ubuntu 14.04, so I download intel_code_builder_for_opencl_2015_ubuntu_5.0.0.43_x64.tgz and extract it.
$ ls -al
total 80
drwxr-xr-x 4 tmax tmax  4096 Jan 19  2015 .
drwxrwxr-x 6 tmax tmax  4096 Dec 29 14:22 ..
-rw-r--r-- 1 tmax tmax 23667 Jan 18  2015 EULA.txt
-rwxr-xr-x 1 tmax tmax   180 Jul 12  2014 install_GUI.sh
-rwxrwxr-x 1 tmax tmax 26066 Jan 19  2015 install.sh
drwxr-xr-x 6 tmax tmax  4096 Jan 19  2015 pset
-rw-rw-r-- 1 tmax tmax  1006 Jan 18  2015 PUBLIC_KEY.PUB
drwxrwxr-x 2 tmax tmax  4096 Jan 19  2015 rpm
-rw-rw-r-- 1 tmax tmax  1223 Jan 19  2015 silent.cfg

They provide convenient shell script for easier install. Just type enter key. Officially this version is supporting only Ubuntu 12.04. But it works well on 14.04

After then clinfo shows the following.

Number of platforms:                             2
  Platform Profile:                              FULL_PROFILE
  Platform Version:                              OpenCL 1.2 LINUX
  Platform Name:                                 Intel(R) OpenCL
  Platform Vendor:                               Intel(R) Corporation
  Platform Extensions:                           cl_khr_icd cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_depth_images cl_khr_3d_image_writes cl_intel_exec_by_local_thread cl_khr_spir cl_khr_fp64
  Platform Profile:                              FULL_PROFILE
  Platform Version:                              OpenCL 1.2 CUDA 7.5.23
  Platform Name:                                 NVIDIA CUDA
  Platform Vendor:                               NVIDIA Corporation
  Platform Extensions:                           cl_khr_byte_addressable_store cl_khr_icd cl_khr_gl_sharing cl_nv_compiler_options cl_nv_device_attribute_query cl_nv_pragma_unroll cl_nv_copy_opts

  Platform Name:                                 Intel(R) OpenCL
Number of devices:                               1
  Device Type:                                   CL_DEVICE_TYPE_CPU
  Device ID:                                     32902
 ....
  Platform ID:                                   0x1b90ad0
  Name:                                                  Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
  Vendor:                                        Intel(R) Corporation
  Device OpenCL C version:                       OpenCL C 1.2
  Driver version:                                1.2.0.43
  Profile:                                       FULL_PROFILE
  Version:                                       OpenCL 1.2 (Build 43)
  Extensions:                                    cl_khr_icd cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_depth_images cl_khr_3d_image_writes cl_intel_exec_by_local_thread cl_khr_spir cl_khr_fp64
  Platform Name:                                 NVIDIA CUDA
Number of devices:                               1
  Device Type:                                   CL_DEVICE_TYPE_GPU
  Device ID:                                     4318
  Max compute units:                             2
  Max work items dimensions:                     3
  ....
  Platform ID:                                   0x1b9bff0
  Name:                                          GeForce GT 530
  Vendor:                                        NVIDIA Corporation
  Device OpenCL C version:                       OpenCL C 1.1
  Driver version:                                352.63
  Profile:                                       FULL_PROFILE
  Version:                                       OpenCL 1.1 CUDA
  Extensions:                                    cl_khr_byte_addressable_store cl_khr_icd cl_khr_gl_sharing cl_nv_compiler_options cl_nv_device_attribute_query cl_nv_pragma_unroll cl_nv_copy_opts  cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_fp64

OpenCL should support multiple implementations on the same system( https://www.khronos.org/news/permalink/opencl-installable-client-driver-icd-loader ). You can see icd files in /etc/OpenCL/vendors/. They describe vendor driver names. libOpenCL.so is a simple wrapper. The core logic is located in the vendor own driver files.
$ tree /etc/OpenCL/
/etc/OpenCL/
└── vendors
    ├── intel64.icd -> /etc/alternatives/opencl-intel-runtime-icd
    └── nvidia.icd
There is one question. Which vendor should provide libOpenCL.so ? Intel and Nvidia provide their own libOpenCL.so. Now, I am using Intel-provided one. I did not test full combinations. According to my 1-year-ago test, some combination of libOpenCL.so and OpenCL Implementation from different vendors is not working well. (Because I did not test it seriously, my conclusion can be wrong.) I used Only one platform. It is just a parallel computing, not Heterogeneous one.

Anyway now it is OK. Whoever make it, libOpenCL.so should work well on different vendor-provided binaries.

Thursday, August 27, 2015

Apache, MySQL, PHP, JavaScript, JQuery

Development Install

sudo apt-get install apache2
sudo apt-get install mysql-common mysql-server mysql-client
sudo apt-get install php5-common php5-mysql libapache2-mod-php5
sudo apt-get install phpmyadmin  // for easier manipulating mysql

sudo service apache2 restart

MySQL

$ mysql -u root -p

Python Django for Web Development

Install on Ubuntu

sudo apt-get install python-django
//sudo apt-get install libmysqlclient-dev
sudo apt-get install python-mysqldb
//sudo apt-get install python-mysql.connector

Install the latest Django on Ubuntu

sudo apt-get install python-pip
sudo pip install -U pip
sudo pip install Django (or sudo pip install Django --upgrade )
./manage.py runserver 0.0.0.0:8000

sudo apt-get install python-dev
sudo pip install Pillow   // for handling modelsImageField (django 1.8)

chgrp -R www-data ./media


Install PyDev on Eclipse

WSGI

 sudo apt-get install libapache2-mod-wsgi

Examples

Tuesday, February 03, 2015

My Linux Setup

Bootable USB using Startup Disk Creator

Window 8.1 & Ubuntu 12.04 Dual Booting by using Boot-Repair

$ sudo add-apt-repository ppa:yannubuntu/boot-repair
$ sudo apt-get update
$ sudo apt-get install boot-repair

!!! Read the guide carefully

Recover Grub using grub rescue

grub rescue > ls
(hd0) (hd0,msdos5) (hd0,msdos3) (hd0,msdos2) (hd0,msdos1) (hd1) (hd1,msdos1)
grub rescue > ls (hd0,msdos1) # try to recognize which partition is this
grub rescue > ls (hd0,msdos2) # let's assume this is the linux partition
grub rescue > set root=(hd0,msdos2)
grub rescue > set prefix=(hd0,msdos2)/boot/grub # or wherever grub is installed
grub rescue > insmod normal # if this produced an error, reset root and prefix to something else ..
grub rescue > normal

Dual Graphic Cards Setup

Korean Input Setup

1. Dash Home -> Language Support -> Install/Remove Language -> Install "Korean"








2. Right Click Upper-right side "Keyboard" Button. -> Restart



3. Right Click "Keyboard" Button -> Double Click "preference" -> Show IBus Preference -> Check Input Method










Utilities

  • apt-file : for searching packages including files to install
    • apt-file search <file_name>
  • apt-cache :
    • apt-cache show <package_name>
  • gnome-color-chooser
    • for customizing ubuntu gnome color appearance
    • for Eclipse Tooltip customizing