import site failed; use -v for traceback

Kept getting this message when I ran the python interpreter under Windows

`import site failed; use -v for traceback

Turns out the PYTHONPATH environment variable was damaged. Fix by right My Computer –> Properties (or Windows key + break) –> Advanced –> Environment Variables

Edit (or New)

Variable name = PYTHONPATH

Variable value =C:\PYTHON26;C:\PYTHON26\DLLS;C:\PYTHON26\LIB;

Running Multiple GPGPU Programs at The Same Time

The speech recognition decoder I work on has the ability to perform some of the computation on the graphics processing unit (GPU). I was recently asked if multiple instances of the decoder could access the GPU at the same time and if so what the performance penalty was. I knew multiple instances could access the GPU at the same time but was unsure of the performance cost.

To evaluate the slow down a single instance of decoder was run on a standard Japanese evaluation task using the corpus of spontaneous (CSJ). The models comprised of seta tri-gram language model compiled to an integrated weighted finite state transducer (WFST) and 3000 state acoustic model with 32 Gaussians per mixture. The same evaluation was then re-run but with two instances of the decoder performing the same evaluation at the same time. The times for the GPU simultaneous plot were calculated as the average of these concurrent runs. The beams widths of the decoder were altered to generate the below RTF vs accuracy plot.


There is a noticeable slowdown when two decoders are running at the same time. The next question is whether this is due to overall system loading or the concurrent accesses to the  GPU.The next experiment is a re-run with  the decoder running with the standard on-demand CPU (SSE accelerated) acoustic scoring.


Overall the slowdown for the CPU only decoder looks larger then the GPU accelerated decoder. Possible explanations are the GPU decoder might have lower memory bandwidth requirements as only acoustic model scores the entire sets of acoustic model parameters need to be moved across the memory buses.

The slowdown factor (simultaneous/exclusive) time is shown below and illustrates that the GPU accelerated decoder is less effected  when multiple decoder are running together. Because the slowdown factor is less than two it also shows it is more efficient to process the data in parallel across two slower decoders rather than all of the data though a single faster decoder. Another important aread is whether a a single multithreaded decoder can perform any better.



Finally for completeness the performance of all decoding runs are shown below.


Further things to consider would be running four decoders together on single machine, or running the decoder on a machine with multiple GPUs.

Compiling HTS Engine for the CLR

For a project I would really like to be able to get HTS Engine to run Silverlight. Managed c++ isn’t supported in Silverlight, I’m trying to think of other ways to compile it to MSIL.

The first technique I have tried is to compile it as managed c++ and then to try and convert the MSIL to C# and recompile again for Silverlight. It seems as this won’t work because of the dependencies on unmanaged functions such as fopen. However it might be useful for someone who wants to create a .NET compatible library for use in .NET programs on the desktop CLT

  1. First grab the hts_engine source code and unpack
  2. Rename the c file to cpp
  3. Edit the makefile.mak in lib and bin dirs and add the /CLR CFLAG and change /TC to /TP. In the bin/makefile.mak change .c to .cpp.
  4. Copy HTS_engine.h into the lib and bin dirs
  5. Open the Visual Studio command prompt and cd into the hts_engine dir
  6. nmake –f makefile.mak all

If the process worked you can verify it is managed compatible by looking at hts_engine.exe in ildasm


Other options are I though to try next for a fully managed port are:

  • A C++ to C# converter
  • MSIL backend for LLVM

Getting Lidia Mangu’s Consensus Code to Run on a Recent Machine

I just noticed that confusion network code is available on line. The code is a little bit vintage these are the steps I took to get it to run on Fedora Core 10.

  1. Locate an an old linux machine (or install one in a VM) with a sub gcc 3 installed, mine was gcc296.
  2. Unpack the code and in the src directory make the changes to the following files.
  3. Comment out the line 25 in //extern "C" void *__builtin_alloca(...);
  4. Comment out line 35 in  //extern int errno;
  5. In CLP/src type the following: 
  6. make -f Make.depend depend 
  7. Edit the makefile based on you compiler location, I added static linkage to the move the binary too machine. CXX = /usr/bin/g++296 CC = /usr/bin/gcc296 LDLIBS = -lm –static
  8. Now build the code with make Consensus

If it worked the CLP/bin dir should contain the program called Consensus . Copied everything to an F10 machines and successfully by by:

cd List

../bin/Consensus -i latlist -R ../data/prons

The produced the output

OKAY GOOD (sw2121A-ws97-l-0001)

The –R and –i and command are essential if they are missing or invalid the application segmentation faults.

Unable to load DLL The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Kept getting this error when pinvoking a c dll from a c#. The outside error was just it couldn’t find the unmanaged dll. Which wasn’t very helpful as it was definitely in the same dir as the .NET exe. Even after putting the unmanaged dll in System32 the error persisted.

It turns out if the unmanaged dll has a dependency on another dll which was missing but it will throw the standard can’t find file error but not give the name of the next dll in the dependency chain. The inside message was “Unable to load DLL The specified module could not be found. (Exception from HRESULT: 0x8007007E)”

Dependency walker can be used on standard dll to display dependency information, unfortunately it doesn’t visual studio anymore so grab a copy here . Open the unmanaged dll and see are other dependences.

In my case libgvc-4.dll was present but C# app was throwing errors like it missing. Dependency walker shows the missing decencies in yellow as shown below. After adding the missing dlls the problem was solved.


PDF Kanji Dictionary for the Pre-2010 JLPT Level 2

A few years ago I was really into studying Japanese and interested in dictionaries and typesetting. I built a system to typeset Japanese Kanji dictionaries, but for the last few years I haven’t working on the system. One of the dictionaries I made was based on the Kanji and vocabulary which appears in the (pre-2010) JLPT level 2 examination. Quite a few people have asked about the dictionary so I am making a version available to download. Below is example entry from the dictionary (The pdf version is much higher quality).

Pages from JLPTDict2

I’m also making another version available that features the animations from embedded right into the document. When I was using Adobe 6.0 full version I discovered that it was possible to embed Flash applets. The possibility of creating beautiful printing documents that could offer interactive and advanced program like functionality when viewed on screen really interested me. For a kanji dictionary it would allow for stroke order diagrams to be displayed with full animation it allows for the direction to displayed in very clean manner. I’ve successfully viewed the animations in Acrobat readers 9.2 and 9.3 with Japanese language supported installed and I have Flash Player 10 on Windows. The animation does not work with MacOSX native pdf viewer and also do not seem to work under Ubuntu.

When viewing the document Acrobat will first prompt for permission to allow embedded content, after a small delay a the animation like the one below should appear in the document. Single clicking on the character should start the animation. After allowing the embedded content there is normally a slight delay, scrolling the document or clicking around seems to speed things up.

The files can be found are available at