Archive for the ‘ubuntu’ Category

Install GTSVM in Ubuntu using CUDA 5.0

June 12th, 2013 1 comment

In order to install this library for fast svm calculation you must download the src from:

Once downloaded you should type:

tar -xvzf gtsvm_src.tgz
cd gtsvm_src

After this you will probably have this error:
headers.hpp cuda_runtime.h no such file or directory

Open the Makefile and add the path to your cuda_runtime.h file. On line 29:

DEFINE_FLAGS := -I/usr/local/cuda-5.0/include/

That is the path in my installation. You should also comment line 24 –> “mex” subfolder. After this you should be able to compile.
If you want an even faster svm regardless the accuracy.
Add -use_fast_math at the beginning of line 36

NVCC_FLAGS := -use_fast_math.

Then a problem could came up:
/usr/bin/ld -lcudart cannot find

Find the path to you can use locate Then add this path to the line 71 and 88 in

LINKER_FLAGS := -L/usr/local/cuda-5.0/lib64

After this just type make and you should be able to compile the source code.

Categories: cuda, ubuntu Tags: , ,

Install Pyopencl and CUDA 5.0 on Ubuntu 13.04 64 bits using nvidia optimus with Bumblebee and Primus

May 31st, 2013 2 comments

The main motivation for this post is how difficult was for me run pyopencl on my fresh ubuntu 13.04 installation. First of all nvidia drivers don’t work well on ubuntu; I am still unable to run nvidia-settings in order to change xorg.conf to run ubuntu-desktop with nvidia card.

Let’s start sharing what I did to achieve running pyopencl programs on ubuntu.

Since my graphics card is an optimus enabled, I followed this wonderful post in which this guy explains how to use your discrete nvidia card to run steam for linux. He states that you should NOT install nvidia-drivers directly so you should have a clean installation.

Basicly to make optimus work Bumblebee should be installed in our system. These are the summarized steps from cjenkins blog:

Bumblebee and Primus installation with nVidia propietary driver

sudo add-apt-repository ppa:bumblebee/stable
sudo add-apt-repository ppa:ubuntu-x-swat/x-updates
sudo apt-get update
sudo apt-get install bumblebee bumblebee-nvidia
sudo shutdown -r now

To run programs with the nvidia card you require to type in a terminal optirun followed by the name of the program you would like to run, such as:

optirun glxspheres
optirun glxgears

You can check how increase the performance by just running them without optirun with your low power graphic card.

If you want to get even better performance install Primus:

sudo add-apt-repository ppa:zhurikhin/primus
sudo apt-get update
sudo apt-get install primus

Test Primus

vblank_mode=0 optirun -b primus glxspheres

(Optional and recommended: use latest nvidia-drivers)

Just in case this does not work for you or you want to run bumblebee with the latest nvidia drivers, you can try this post. Summarizing they installed the latest nvidia-drivers in that time (nvidia-experimental-310) and then he changed configuration files for bumblebee and for primus as well:

I have to say that I followed the steps in the same way but I hope someone else tries with the latest nvidia-drivers.

sudo apt-get install nvidia-310-updates nvidia-experimental-310 nvidia-settings-310-updates

Modify bumblebee configuration file:

sudo vim /etc/bumblebee/bumblebee.conf

– on line 22, make sure “Driver=” is set to “nvidia”, like this:

– change the “KernelDriver=” (on line 55) to “nvidia-experimental-310”, like this:

– change “LibraryPath=” (on line 58) to “/usr/lib/nvidia-experimental-310:/usr/lib32/nvidia-experimental-310”, so it looks like this:

– change the “XorgModulePath=” (line 61) to “XorgModulePath=/usr/lib/nvidia-experimental-310/xorg,/usr/lib/xorg/modules” so it looks like this:

Restart Bumblebee

sudo service bumblebeed restart

Logout and Login and try

optirun glxspheres

If you are using primus modify script /usr/bin/primusrun in line 16 changing nvidia-current with the nvidia-driver you installed. Same in line 27.

After this you should be able to run bumblebee and primus together and get the best from your graphic card.

Installing CUDA toolkit

Now that our nvidia drivers are working next step will be install CUDA toolkit to work with it. I will summarize this excellent post in the following steps:

Downloads =>
=> CUDA pack from
=> pyopencl from

I was just interested in pyopencl so I will focus in that part. Then in a terminal:

sudo vim /etc/environment

==> and add to PATH line the following ‘:/usr/local/cuda-5.0/bin’

sudo vim /etc/ 

==> and add lines: /usr/local/cuda-5.0/lib and /lib

sudo vim /etc/bash.bashrc 

==> add lines to the end

export PATH=/usr/local/cuda-5.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-5.0/lib:$LD_LIBRARY_PATH

Then run the following commands:

sudo ldconfig
sudo apt-get install freeglut3-dev python-opengl python-pytools python-setuptools python-numpy libboost1.48-all-dev
sudo apt-get install build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev
sudo ln -s /usr/lib/x86_64-linux-gnu/ /usr/lib/
sudo sh

Once the installer is running there are some issues I had the first one don’t install the nvidia-drivers from the pack just type no at the moment of installation.
Type y for CUDA toolkit and SAMPLES (optional).

The reason why you should not install the nvidia-drivers from the pack, you will probably get this error:

ERROR: The kernel header file
       ‘/lib/modules/3.8.0-22-generic/build/include/linux/version.h’ does
       not exist.  The most likely reason for this is that the kernel
       source files in ‘/lib/modules/3.8.0-22-generic/build’ have not been

Next Possible error with the toolkit is the following one:

Unsupported compiler: 4.7.3


sudo apt-get install gcc gcc-4.4
sudo update-alternatives --remove-all gcc
sudo update-alternatives --config gcc
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 20
gcc --version

Missing required library


sudo ln -s /usr/lib/x86_64-linux-gnu/ /usr/lib/

Installing PyOpenCL

Once you have CUDA installed you should proceed to install pyopencl:

python   --boost-inc-dir=/usr/include/boost   --boost-lib-dir=/usr/lib   --no-use-shipped-boost   --cl-inc-dir=/usr/local/cuda-5.0/include/   --cl-lib-dir=/usr/lib/nvidia-310-updates/  --cl-libname=OpenCL
sudo make install

After I got to install pyopencl successfully a last error showed up:

clGetPlatformIDs failed: platform not found khr


If you just have this one


Create a link and write in nvidia.icd the link

ln -s
echo | sudo tee /etc/OpenCL/vendors/nvidia.icd
cd examples
optirun python

After this you should be able to run pyopencl scripts with optirun

Extract files from a directory to another by file extensions

May 19th, 2013 No comments

Due to the complexity of the folders created for testdisk, I decided to implement a script to get the data I am interest in.
Copy this script and save it as in the directory you would like to scan. Run the script on the terminal by:

python “/home/username/path-to-folder”

The argument is the path where you are going to save your extracted files.

import os
import shutil
import sys, getopt
from os.path import join, getsize

def main(argv):
    path = '.'
        opts, args = getopt.getopt(argv,"")
    except getopt.GetoptError:
        print ' "path"'
    for root, dirs, files in os.walk(path):
        for name in files:
            if name.endswith((".jpg",".mov",".mp4")) and getsize(join(root,name))/1024 > 100:
                print name, getsize(join(root,name))/1024
                shutil.copy2(join(root,name), args[0])

if __name__ == "__main__":

Once finished you will have in the folder you specified all the files greater than 100Kb and with extensions “.jpg”,”.mov” and “.mp4”. Feel free to add the extensions you want.

Categories: python, ubuntu Tags: , , ,

Recover deleted and unreadable files from ubuntu

May 18th, 2013 No comments

One sector of my hard drive is unreadable and my pictures folder are not visible to the OS. Digging on internet I found a useful application to recover them back. You can download testdisk from

I used live ubuntu from my USB flashdrive to perform testdisk installation in order to keep integrity of the data on hard drive. Once you are on ubuntu run:

tar xjvf testdisk-6.xx.tar.bz2

cd testdisk-6.xx

You will find three applications: fidentity_static, photorec_static and testdisk_static. The one of my interest is photorec_static to recover media from my partition unreadable.

sudo ./photorec_static

The interface is on terminal and you have to select the partition you would like to recover files, and then the location where you would like to write the recovered files. Don’t use the same disk to save your recovered data use an external hard drive.


Categories: data loss, ubuntu Tags: ,

Mediacore error PIL – IOError: decoder jpeg not available

March 7th, 2012 No comments

There is an error with mediacore community edition installation, when you try to upload a thumbnail to a video it shows Error 2038 and it can’t upload the image.
It is because PIL that comes with the mediacore installation didn’t find paths to the libjpeg and zlib libraries. To solve this you have to:

  1. Download PIL 1.1.6
  2. Delete mediacore_env/lib/python2.7/site-packages/PIL
  3. Delete mediacore_env/lib/python2.7/site-packages/PIL.pth
  4. Delete mediacore_env/lib/python2.7/site-packages/PIL-1.1.6-py2.7-linux-x86_64.egg
  5. tar -xvzf Imaging-1.1.6.tar.gz
  6. cd Imaging-1.1.6
  7. python install
  8. cd mediacore-community
  9. paster serve –reload development.ini

Then It should work !

Categories: python, ubuntu Tags:

EnvironmentError: mysql_config not found

March 6th, 2012 No comments

When you get this error, you just need to install libmysqlclient-dev. In ubuntu use:

sudo apt-get install libmysqlclient-dev

Categories: ubuntu Tags: ,

Install VLC on ubuntu 64 bits

September 23rd, 2011 No comments

Once you have installed ffmpeg and x264, in the way I posted before, it is time to install vlc.

tar xjvf vlc-1.1.11.tar.bz2
cd vlc-1.1.11/

If there is an error in the configure probably could be the libqt4-dev

sudo apt-get install libqt4-dev
sudo make install
ln -s /usr/local/lib/libvlc* /usr/lib/
ln -s /usr/local/lib/libx264.a /usr/lib/
ln -s /usr/local/lib/vlc /usr/lib/vlc

Once you have done this you can use vlc as a player, but if you would like to stream some multimedia content you will see an error like “stream_out_standard stream out error: no suitable sout mux module for `udp …” and “no sout mux module matched” and “main stream output error: stream chained failed for ‘standard {mux=” etc.

To solve this install libdvbpsi:

sudo apt-get install libdvbpsi6
sudo apt-get install libdvbpsi-dev

After that type:

make install

Finally you will have working vlc and ffmpeg together, without conflicts !


Categories: vlc Tags: , , ,

Force to mount an internal windows drive in ubuntu

September 17th, 2011 No comments

Follow these steps:

1.- Open a terminal
2.- Type sudo /bin/bash
3.- Now, type mkdir /media/windisk
4.- To know which is the partition type: fdisk -l
5.- For ntfs drives type: mount -t ntfs-3g /dev/sda1 /media/windisk -o force
For fat32 drives type: mount -t vfat -o umask=000 /dev/sda1 /media/disk

Now you can access to your windows partition

Categories: ubuntu Tags:

Installing libx264 and ffmpeg on Ubuntu 11.10 – 64 bits

August 23rd, 2011 7 comments

The main goal to compile and install libx264 and ffmpeg is try to make work vlc and ffmpeg at the same time.

First remove old installation

sudo apt-get remove ffmpeg x264 libx264-dev

Install all the packages you will need

sudo apt-get update
sudo apt-get install build-essential checkinstall git libfaac-dev libjack-jackd2-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libva-dev libvdpau-dev libvorbis-dev libx11-dev libxfixes-dev libxvidcore-dev texi2html yasm zlib1g-dev

Install X264

Install x264 packages getting the source code using git
Install git with:

sudo apt-get install git
git clone git://
cd x264/
./configure --enable-shared
sudo make install

Install ffmpeg

Install ffmpeg packages getting the source code using git

git clone git://
cd ffmpeg/
./configure --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --disable-ffplay --enable-shared --enable-gpl --enable-postproc --enable-version3 --enable-nonfree --enable-avfilter --enable-pthreads
sudo make install

Configure global variables:

export LD_LIBRARY_PATH=/usr/local/lib
sudo gedit /etc/

//add this –> /usr/local/lib at the end of the file

sudo ldconfig
hash x264 ffmpeg ffplay ffprobe or
hash x264 ffmpeg ffprobe</p>
Categories: ffmpeg, ubuntu Tags: , , ,

no screens found error

May 3rd, 2011 1 comment

Today I had a problem with my recently upgraded ubuntu 11.04. At the initialization process it couldn’t load the X server, and when I run startx in a console, it give me as error no screens found.

The solution is editing a line in the /etc/X11/xorg.conf . At Section “Device” edit BusID field with the address of your graphics card, in my case “PCI:1:0:0”. You can find your address using lspci Then reboot.

It should be solved. Special Thanks to freq101. Complete tutorial:

Categories: startx problems, ubuntu Tags: