Suspend and hibernate in Linux



After installing ubuntu 14.04 I found hibernation was disabled. It was deleted from system menu at all.  http://ubuntuhandbook.org/index.php/2014/04/enable-hibernate-ubuntu-14-04/
 Only Suspend option was there.
 Suspend didn't work either. Computer couldn't wake up. It actually woke up, but stayed freezed displaying wallpaper.
Some googling and testing with other hibernation modules (tuxonice),  swap settings gave no result.
I decided to install mint Linux as it has hibernation option by default.
In mint Linux the situation was the same except I hadn't to enable hibernate option myself.
The solution was in using proprietary Nvidia drivers instead of open source.
In mint Linux there is a convenient tool called driver manager http://www.linuxmint.com/rel_olivia_whatsnew.php
There I switched to a version provided by nvidia. After installation I reboot Computer and suspend/hibernation worked.


Ubuntu developers say they disabled hibernation by default because too many users face issues with hibernation.  I suppose now I know the cause of these issues : bad Nvidia support in open source drivers. :) 

Logging exceptions with traceback in python

When using logging module one often need to print traceback along with error message.
Solution is:
logger.error('error message',  exc_info=True)  # for adding traceback to log

Equivalent :
logger. exception('message') 

Installing Ubuntu from USB

I use  Windows OS and I want to install Ubuntu on another PC.
1. Download software for bootable usb creation
http://www.pendrivelinux.com/universal-usb-installer-easy-as-1-2-3/
2. Download ubuntu image from
http://www.ubuntu.com/download/desktop
3. According to instructions from http://www.ubuntu.com/download/desktop/create-a-usb-stick-on-windows install image on usb stick
4. use usb-stick as bootable

Installing theano on windows

0. install Anaconda
1. download Theano sources from git (install it using setup.py)
2. Setup NVIDIA GPU Toolkit. I have installed version 6.5
3. Setup Visual Studio Community Edition 2013
4. Create config file .theanorc  in c:\Users\X\:

[global]
floatX = float32
device = gpu

[nvcc]
fastmath = True
compiler_bindir=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe


Without the line with path to cl.exe I got:
nvcc fatal   : Cannot find compiler 'cl.exe' in PATH
['nvcc', '-shared', '-O3', '-use_fast_math', '-Xlinker', '/DEBUG', 
'-D HAVE_ROUND', '-m64', '-Xcompiler',
 '-DCUDA_NDARRAY_CUH=f411a53ee0a470fbaad3b5c4a681ef64,-D 
NPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION,/Zi,/MD', 
'-Ic:\\anaconda\\theano\\theano\\sandbox\\cuda', 
'-Ic:\\anaconda\\lib\\site-packages\\numpy\\core\\include', 
'-Ic:\\anaconda\\include', '-o', 
'C:\\Users\\X\\AppData\\Local\\Theano\\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_42_Stepping_7_GenuineIntel-2.7.7-64\\cuda_ndarray\\cuda_ndarray.pyd', 
'mod.cu', '-Lc:\\anaconda\\libs', 
'-Lc:\\anaconda', '-lpython27', '-lcublas', '-lcudart']


Writing simple optical flow in python. Part 3

Today, my imaginary readers, we improve our optical flow dramatically. Lets see, what our algorithm produces for images that have more than 1-pixel shifts.

I0 I1
OF results:


You can see, that the algorithm cannot deal with too large displacements. Even with multiple warps.
Lets apply multiscale scheme now. We need to construct image pyramid:

Writing simple optical flow in python. Part 2

After fixing some errors, it seems my OF is working.


Image I0
Image I1
first iteration OF
1st iteration of warped I1
Second Iteration OF
Second iteration of warped I1
3 iteration Of
3rd iteration of warped I1
Last iteration