Sunday, November 12, 2017

TensorFlow on MX150

One can run TensorFlow on NVidia GeForce MX150 graphics card using the following setup:
  • CUDA version 8.0
  • CuDNN version 6.0 for CUDA 8.0
Timing comparison for matrix multiplication using CPU (i7-8550) (shown in orange) and GPU (MX150) (shown in blue) for increasing matrix sizes.
 
{'/gpu:0': [0.23459196090698242, 0.5798056125640869, 0.08466935157775879, 0.0998234748840332], 
'/cpu:0': [0.7988660335540771, 4.3423473834991455, 14.469173431396484, 42.78021287918091]}

The code for doing the matrix multiplication is given here.

Saturday, November 11, 2017

From OSX to Windows 10 and WSL

After several years of using Macbook Pro laptops, I recently shifted to Windows 10 and find myself often searching for things which are not clearly documented on or can be found via Googling. This post aims to collect the different settings necessary for reaching a seamless setup for working on Windows 10 using the Linux subsystem.

Overview

Setting up WSL is well-documented on https://msdn.microsoft.com/en-us/commandline/wsl/install-win10.
.bashrc (or .zshrc) should have the following commands:
export NO_AT_BRIDGE=1
export DISPLAY=:0
umask 022

Getting graphical display to work

There are two key components when trying to setup X connectivity between WSL. This is discussed on https://www.reddit.com/r/Windows10/comments/4rsmzp/bash_on_windows_getting_dbus_and_x_server_working/.
  • X server: I use vcXsrv which works fine and then insert the following code in the .bashrc file:
    export DISPLAY=:0
  • DBus configuration: If the DBus configuration is not fixed, one gets warnings similar to the one listed below.
    (emacs:622): GConf-WARNING **: Client failed to connect to the D-BUS daemon: /usr/bin/dbus-launch terminated abnormally without any error message process 622: D-Bus library appears to be incorrectly set up; failed to read machine uuid: UUID file '/etc/machine-id' should contain a hex string of length 32, not length 0, with no other text See the manual page for dbus-uuidgen to correct this issue.
    This can be fixed using the following commands:
    sudo apt-get install dbus-x11
    sudo dbus-uuidgen --ensure
    

Installing LaTeX

The generic latex installation can be done using the following command
 
sudo apt install texlive texlive-latex-extra texlive-generic-extra

Changing CAPS Lock to CTRL

Windows has done an excellent job with language settings. Having bought a laptop in Germany, I have a German keyboard. After changing the language and restarting, the news feeds and OneNote language setup are also changed. Brilliant Work. However, for people used to Emacs - the CAPS Lock is often mapped to Control and vice versa. One can achieve the same in Windows using Sharp Keys which edits the Windows registry. I do not recommend AutoHotkey due to being too complex and not providing an uninstaller.

Friday, November 12, 2010

Matlab's keyboard command in python

A nice function to mimic matlab's keyboard command in python.

import code
import sys
def keyboard(banner=None):
    ''' Function that mimics the matlab keyboard command '''
    # use exception trick to pick up the current frame
    try:
        raise None
    except:
        frame = sys.exc_info()[2].tb_frame.f_back
    print "# Use quit() to exit :) Happy debugging!"
    # evaluate commands in current namespace
    namespace = frame.f_globals.copy()
    namespace.update(frame.f_locals)
    try:
        code.interact(banner=banner, local=namespace)
    except SystemExit:
        return 

Friday, September 17, 2010

LaTeX Todo's

A very interesting package todonotes, allows keeping track on unfinished items in a LaTeX manuscript by posting colorful notes on the margin and a table of changes to be made. Available at
http://www.ctan.org/tex-archive/macros/latex/contrib/todonotes/

Monday, March 22, 2010

Matlab-Java Integration, Working note.

Since Matlab runs on a JVM, it can easily integrate JAVA classes. Here is a quick view, mostly taken from the Matlab documentation.
 
[mFns, mexFns, javaClasses] = inmem; %Check which classes in memory

% classpath 
which classpath.txt
edit classpath.txt 

% imports
import java.lang.String
L = import % return import list 

% creating objects
strObj = javaObject('java.lang.String', 'Hello World')
frame = java.awt.Frame('Frame A') 
setSize(frame, 800, 400)
newFrameRef = frame

% concatenating object using cat or [] 
myObjs = [strObj; frame] 

% save trial.mat myObjs 
% load trial.mat 

% getting class attributes
names = fieldnames(strObj, '-full') % second argument optional 

% accessing object data
frameDim = getSize(frame) 
h = frameDim.height 

w = java.awt.Frame.WIDTH % static data, say, counters

% test class name
if (isjava(obj))
    name = isa(obj, 'class_name')
end

% invoking methods
% obj.method(args) OR method(obj, args) 
getTitle(frame) 
javaMethod('startsWith' , gAddress, str) % longer method names
java.lang.Double.isNaN(2.2) % static methods
javaMethod('isNaN' , 'java.lang.Double', 2.2) % static javaMethod 

methodsview java.awt.Frame % class name 

javaArray('java.lang.Double', 4, 5) 

Saturday, February 13, 2010

try out buzz - blogspot integration

Trying to incorporate this in google buzz

ComputerScience@Mattel


Mattel Inc, makers of Barbie Dolls are releasing a new Barbie, who is a computer engineer (Related IEEE Spectrum Article).

The release is scheduled for tomorrow coinciding with Computer Engineers Week starting tomorrow. One might wonder with the choice of the organizers starting the week to coincide with Valentine's Day :)

This is especially relevant considering the fact that the number of women in CS is decreasing; and the special incentives both by the Industry and Academia to promote women in the field, e.g., Anita Borg awards, IBM's EXITE, etc.

Personally, I wish luck to the efforts :)