Fedora 17 is up, and ready to be downloaded and used.. Cheers to the Fedora team for a wonderful release… !!!
ANN (Approximate Nearest Neighbours) is an extremely useful library when working with any type of application where the properties of data points are influenced by their neighbours. The MATLAB MEX-wrapper for the same provided by Shai Bagon, along with the patches, compiles effortlessly in Linux (have tried on F16 and F17). However, making the same work in Windows turned out to be quite an effort. First, the MATLAB inbuilt compiler for Windows (lcc) continuously kept crashing whenever I tried executing the library, and second, the lack of pre-existing solid C/C++ compiler made things difficult.
After searching on the net for free and supported compilers for MATLAB R2010a, I first tried Open Watcom, but it gave too many errors during compilation of the mex-wrappers. Then it was the turn to check out MS Visual C++ Express Edition. Tried on a friend’s system having MS-VC++ 2010, and it too gave quite a few errors during compilation. Thought to try out MS-VC++ 2008, and guess what, it worked out of the box and the mex-wrapper compiled with quite an ease 🙂 . Wonder why MS-VC++ 2010 created issues..
( Update: have posted a MUCH simpler method of driver install. Steps for CUDA toolkit install have to be followed as given in this post, i.e. , bulleted step # 10 – 19 )
Although the topic has been addressed succinctly in a CentOS forum post, there are certain things like plymouth configuration post Nvidia driver install, etc. which I felt needed to be jotted down for reference. So, here we go describing the Nvidia CUDA toolkit installation on a CentOS system:
- Download the appropriate toolkit, driver and SDK from Nvidia’s website.
- RHEL, and its derivatives come with the open source Nvidia driver called nouveau. Before installing Nvidia drivers, we need to ensure nouveau drivers dont get loaded. For this, append the following in the line starting with ‘kernel’ in the file /etc/boot/grub.conf:
- Install the Development Tools and Development Libraries group packages, and a few extra packages listed below:
sudo yum groupinstall ‘Development Tools’ ‘Development Libraries’
sudo yum install kernel-devel gcc-c++ freeglut freeglut-devel libX11-devel mesa-libGLU-devel libXmu-devel libXi-devel gcc* compat-gcc* compat-glibc* compat-lib*
- Restart the system. Upon restart, you’ll see that the resolution of the display would have gone for a toss. Thats due to blacklisting the nouveau driver, and is a sign that we are on track! Open terminal and type the following to goto non-GUI mode (called, runlevel 3):
sudo init 3
- Above command takes us to text mode. Change directory to /usr/src/kernels/ and note down the complete path of the kernel folder present. In our scenario, it shows up as:
- Change directory to the folder containing the downloaded files from Nvidia’s website (say ~/Downloads). Mark the 3 downloaded files as executables:
chmod a+x NV*; chmod a+x cuda*; chmod a+x gpu*
- Now finally, we are ready to run the installer. First is the Nvidia Driver install :
sudo sh NVIDIA-Linux-x86_64-295.20.run –kernel-source-path=/usr/src/kernels/2.6.32-220.13.1.el6.x86_64/
- NOTE : there’s a double minus sign before the word kernel above. During the above install, accept the licence agreement shown. Reboot upon completion:
- You’ll notice that the GUI resolution is back to normal, indicating successful Nvidia driver install. Now, cudatoolkit has to be installed.
- Open terminal and change directory to ~/Downloads. Run the cudatoolkit*.run file:
sudo sh cudatoolkit_4.0.17_linux_64_rhel6.0.run
- During the install, you’ll be asked to supply installation path. Enter the default path itself (/usr/local/cuda).
- Once completed, few more steps are needed, like adding /usr/local/cuda to default path environment variable, etc. :
sudo nano /etc/ld.so.conf.d/cuda.conf
- Add the following lines to the above created file :
- Save the above file by pressing Ctrl+x, followed by ‘y’ and pressing Enter. Now run:
- For adding cuda install path to enviroment path variable, edit ~/.bash_profile file using a text editor (say, nano ~/.bash_profile) :
export PATH=($PATH: /usr/local/cuda/bin)
export PATH=($PATH: /usr/local/cuda/lib)
- Finally, gpucomputingsdk needs to be installed. For that :
- During the install , you’ll be asked for install path. Keep in mind that the sdk can take around 400-500MB. Say, we install it to ~/Documents/NVIDIA_GPU_Computing_SDK.
- Once done, we need to compile the files in the SDK:
- To check whether everything is working fine, we’ll run the deviceQuery file, provided by the SDK just installed:
- You should see something similar to what is shown at this link .
Congrats for successfully installing the Nvidia driver and the cudatoolkit on your CentOS system. I know, things should be much simpler. I wish someday Nvidia open-sources their drivers and CUDA toolkit to make things simpler for Linux enthusiasts. All that is left now, is to fix the ugly white-blue scrolling bar that shows up instead of the beautiful Plymouth at boot.
- Reboot system. At the grub prompt, press ‘e’ against the first item on the grub menu to edit its kernel arguments (this mode is called kernel edit mode).
- Out the the three lines being shown (starting with : root; kernel; initrd ), scroll to kernel line and press ‘e’ again. Type in the following at the end of that line:
- Press Enter after typing the above and press ‘b’. You’ll see a tabulated list of keywords against several screen-resolutions. Note down the number being shown against the most appropriate screen resolution. Say, the number is 361. Now, reboot system. Again, enter the kernel edit mode described in the previous two list items. The only difference being that instead of vga=ask, enter vga=0x361. Now press ‘b’ and you’ll see the beautiful Plymouth back in its glory!
- To make this change permanent, open terminal and open /boot/grub/grub.conf as sudo (sudo nano /boot/grub/grub.conf).
- Find the line saying ‘kernel’ against your most recent kernel version and add vga=0x361. Save the file (Ctrl+x, y, Enter)
Plymouth theme will now show up everytime that you’ll reboot. Enjoy!
Ever faced the problem of running executables in a MATLAB installation on Linux. I frequently use an executable file (.exe) provided by an eminent research lab, but the linux enthusiast that I am, shifting to Windows just for running this file is out of the question! So, how to solve this issue!
Well, you need access to either a system running Windows at your workplace, or have a virtual Windows installation in VirtualBox. Set up ssh via cygwin (refer SSH via CYGWIN) on such a system and also make sure to have a password-less SSH login enabled (refer ssh autologin) between the Linux and Windows systems.
Once this is done and given the fact that such a Windows environment is up and running, all you have to do through the MATLAB command prompt is:
system(‘ssh username@IP_of_windows command1;command2’);
where : command1 and command2 are the things you want to execute on that system. For e.g: in my scenario, i have already put the .exe (say: test.exe) in the cygwin home folder (C:/cygwin/home/<username>/) on the Windows system. Now, i just run:
system(‘ssh username@IP_of_windows ./test.exe’);
You can use few more ssh/scp via system command calls in MATLAB to copy back & forth the data. Thats it!
It so happens that at times the SSH connection was getting lost (probably due to network issues) with a message “Write failed: broken pipe”, and this resulted in a crash in cluster based codes. Thanks to this Archlinux forum post, i understood the workaround.
Broken pipe results upon communication loss between the client and the server. So, if we can somehow send control signals over the connection within a ‘n’ second of the last data transmission, this problem should be solved. This is exactly what the command ServerAliveInterval does. Smaller the time duration specified, earlier the control signal will be sent, and the connection doesnt drop.
To achieve this, just append at the end the following line to /etc/ssh/ssh_config file at the client side :
sudo nano /etc/ssh/ssh_config
ServerAliveInterval 5 (append at the end of the file)
Now, just restart the ssh daemon and its done!
sudo systemctl restart sshd.service (Fedora / OS having systemd)
sudo service ssh restart (Linux Mint / OS having Upstart)
This will ensure the control signal inquiring Server Alive status is sent 5sec after every time the connection loss happens, and the cluster based codes can run smoothly!
Upon installing Fedora 16 (
Fedora-16-Beta) as a guest OS (via VirtualBox), i was greeted with the Fallback mode, turning my excitement to see Gnome3 in its refined new avatar Gnome3.2 into disappointment. Even installing VirtualBox guest additions didnt help.
Its in such scenarios, that i have found fedora-forums to be the best place to learn the causes and rectify them. Thanks to this thread , i realised its a SELinux policy that prevents gnome-shell from auto kick-starting. Follow these steps to enjoy Gnome3.2 experience :
1) Ensure your guest OS is fully updated. Restart once to boot into new kernel.
sudo yum update
2) Install kernel-devel and gcc, if not already present.
sudo yum install kernel-devel gcc
3) In the VirtualBox Guest GUI, Click : Devices > Install Guest Additions. Provide sudo password when prompted and let the install process complete.
4) Now, Modify the SELInux policy for VirtualBox guest additions as below:
restorecon -R – v /opt
(NOTE: single minus sign is used at both places above)
5) And you are ready to use gnome shell after a reboot. To immediately start it, do:
gnome-shell –replace &
(NOTE : its two minus signs before the word replace ..)
CodeBlocks is one of the IDE(s) that i prefer using due to its simplicity and fast interface. Plus the benefit of having MATLAB like command suggestions. The steps are outlined below:
- Search the path where opencv is installed in your system.. you can do a :
- in my system, this returns : /usr/local/include/opencv/cv.h. Copy the path till the opencv directory, i.e : /usr/local/include/opencv/
- Now, open CodeBlocks > New Project > (any project type of your choice.. for starters, Console Project is a good beginning) . Now goto,
Project > Build Options > Linker Settings tab
- Under “Other Linker options” add the following, one below the other:
- Now, in the same window, under “Search directories tab”, add the opencv directory you copied above, i.e. for my system, it’ll be :
- Now, Project > Properties > C/C++ Parser options, again add the same directory path.
And you are done !! Enjoy compiling OpenCV codes in CodeBlocks 🙂
Much has changed since OpenCV 2.0.. android support, CUDA support, etc are up and running. So is the change in the method of installing OpenCV. So, i though to quickly jot down the steps to follow for a painless install.
I must add, due to changes in gcc, removal of libv4l support from linux kernel, etc.. OpenCV 2.1 and 2.2 give loads of issues during install. I just couldnt manage installing v2.1, though v2.2 needed few hacks as mentioned in the link : https://code.ros.org/trac/opencv/ticket/324 . So, for people wanting to install v2.2, can follow exactly same steps mentioned below after making the above hack. Note that, even UVC-webcams dont work with v2.2. So, if you’re like me, needing lots of webcam feed for vision-based tasks, its best to avoid v2.2. Moral of the story : Go for v2.3..
1. Install the following :
sudo yum install eigen2-devel, CTL, CTL-devel, OpenEXR_CTL-libs, tbb, yasm, yasm-devel, tbb-devel, OpenEXR CTL-devel, OpenEXR CTL, perl-URI, perl-Compress-Raw-Zlib, perl-Compress-Raw-Bzip2, perl-l0-Compress, libucil-clevel, perl-HTML-Tagset, perl-HTML-Parser, perl-Iibwww-perl, perl-XML-Parser, gstreamer-plugins-base-devel, libsigc++20-devel, glibmm24-devel, libxml++-devel, gstreamermm, xine-lib, libunicapgtk-devel, xine-lib-devel, gstreamermm-devel, python-devel, sip-macros, sip, vamp-plugin-sdk, audacity, sip-devel
sudo yum install libXext-clevel, glib2-devel, libXrender-devel, libXﬁxes-devel, Iibunicap, freetype-devel, boost-system, fontconﬁg-devel, libpng-devel, boost-ﬁlesystem, boost-serialization, boost-thread, boost-date-time, boost-regex, libXt-devel, libXdamage-devel, libXcomposite-devel, libXcursor-devel, libXrandr-devel, atk-devel, libXinerama-devel, libXxf86vm-devel, libXi-devel, libxml2-devel, blas-devel, libjpeg-turbo-devel, pixman-clevel, cairo-devel, pango-devel, libdrm-devel, mesa-libGL-devel, boost-graph, boost-wave, libucil, boost-signals, boost-python, boost-iostreams, boost-program-options, boost-random, boost-test, boost, mesa-libGLU-devel, ilmbase-devel, libunicapgtk, gdk-pixbuf2-devel, libibverbs, libmlx4, librdmacm, check, check-devel, boost-jam, rarian, rarian-compat, cmake, plpa-libs, numactl, environment-modules, boost-devel, boost-build, OpenEXR-devel, jasper-devel, lapack-devel, libunicap-devel, libtifl-devel, atlas-devel, openmpi, boost-openmpi, ucview, gstreamer-devel, gtk2-devel, jasper, 0penEXR
sudo yum install xorg-x11-proto-devel, libXau-devel, Iibxcb-devel, libX11-devel, libram1394-devel, automake, libogg-devel, libtheora-devel, libvorbis-devel, libdc1394-devel, x264-devel, faac-devel, xvidcore-devel, dirac-devel, gsm-devel, zlib-devel, faad2-devel, speex-devel, lame-devel, orc-compiler, orc-devel, libvdpau, cppunit, libvdpau-devel, schroedinger-devel, dirac, x264, lame, faad2, amrwb-devel, opencore-amr-devel, amrnb, amrnb-devel
(i have tried copying the package names via OCR software and some editing as much as could be possible from the screenshot below)
Install from Add/Remove Programs (PackageKit)
2. Now, download and Install FFMPEG
- Eventhough FFMPEG is at v0.8.. its best to go for v0.7.. thats coz of several dependency issues. Many things like VLC, etc are based on ffmpeg v0.69 code, and v0.8 MAY give lots of issues..
- Download ffmpeg 0.7 from : http://ffmpeg.org/releases/ffmpeg-0.7.1.tar.bz2
- extract the above file (say files get extracted to /home/user/ffmpeg)
- Open terminal and cd to above location.. i.e. : cd /home/user/ffmpeg
- Now type the following :
./configure –enable-gpl –enable-version3 –enable-nonfree –enable-postproc –enable-libfaac –enable-libopencore-amrnb –enable-libopencore-amrwb –enable-libtheora –enable-libvorbis –enable-libxvid –enable-x11grab –enable-swscale –enable-shared
sudo make install
- And you are done.. FFMPEG is ready to be integrated with OpenCV.
3. Download OpenCV 2.3 . Extract to a folder (say /home/user/Opencv-2.3)
- There still are a few packages of ffmpeg like libavcodec-dev, libavutil-dev, etc which need to be present in /usr/local/ffmpeg/ . But, the above install of ffmpeg doesnt create this. So, open Add/Remove Programs and install following or install using yum:
sudo yum -y install ffmpeg ffmpeg-devel ffmpeg-libs
- Now, the requisite libraries are all present in the location OpenCV can find them. Open terminal and cd to the OpenCV folder.. i.e.
- Create a folder called Release
- cd to the Release folder and type the following to install OpenCV
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D WITH_CUDA=OFF -D WITH_V4L=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_FFMPEG_BUILD=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D WITH_IPP=OFF -D BUILD_EXAMPLES=ON ..
make -j 2
sudo make install
- Few more steps need to be done to ensure flawless build.
sudo gedit /etc/ld.so.conf.d/opencv.conf
(Type the following and save-close the file) : /usr/local/lib
sudo gedit /etc/bashrc
(Type the following and save-close the file) :
And you are done !!! 🙂 OpenCV 2.3 with ffmpeg support is ready to be used on Fedora 15 with full webcam support.. ENJOY !!
NOTE : due to requests for Ubuntu specific steps, i’ll put the changed steps in this post itself in a few days
The awesomeness of Fedora 15 is now out in the wild for everyone to experience If you are amongst the not-so-crazy ones, who have been playing around with the OS since its Alpha days, well.. its time you experience it !
Head to :
And yes, the release banner prepared by the Fedora Design team rocks !! just couldn’t help but posting it here too..
With F15 (Fedora 15) in its final stages before release, have been playing around with my F15 system alot more in the past few days.. Recently observed a REAL nice feature in yum, which has made me a BIG BIG fan of it’s..
Had forgotten that i didnt have deltaiso rpm package installed in my system. So, i typed :
applydeltaiso old.iso delta.diso new.iso
and this is the output :
Well, as can be seen.. yum found the command in a package, and after permission from the user, installed the required package and the dependencies on its own !!! In my view, its a FANTASTIC feature.. the user doesnt have to worry which package provides the command..
Am not sure if this was there in earlier releases of yum, but its a great great feature 🙂 Glad to have discovered it finally, in case the feature existed since before.. and yes, kudos to the yum team !!