z·eeki·sh

tech log on gentoo, linux, and random stuff

Archive for the ‘gentoo’ Category

Wacom Bamboo Create (CTH670) on linux

leave a comment »

Apparently the xf86-input-wacom driver is not enough: one has to manually build the kernel module (for kernel version <= 3.2)

1) get input-wacom driver here: http://sourceforge.net/projects/linuxwacom/files/xf86-input-wacom/input-wacom/
2) unpack and run ./configure. Pay attention to the installation instructions at the end of ./configure output
3) copy kernel modules to /lib/modules/ as instructed.
4) modprobe wacom and enjoy

Advertisements

Written by zsh

February 15, 2012 at 10:53 pm

armadillo, lapack, and intel’s MKL

with 2 comments

I normally use ruby/gsl for everyday numerics because it’s fast to code and extend, and semantically clear, plus you can do cool things like previewing energy spectrum from within irb by interfacing with the gnuplot module—normally you’d write to a tmp file, switch to gnuplot console, and plot it there.

The problem with rb/gsl is speed. The other day, my boss walked in and compiled his fortran code on my machine. It beat my ruby code hands-down—one would think gsl, being a C library, should be on par with lapack, but apparently it’s not, and it’s not (entirely) ruby’s fault since I rewrote the same stuff in C, using gsl, and it’s still about 4 times slower than my boss’s fortran code using lapack. (I guess partly it’s b/c gsl is using its own blas implementation).

So I want something faster but still with natural semantics—e.g., matrix multiplication should be A*B, not dgremm(...A...B...)—so C++ seems a reasonable place to look at. So far I find armadillo suits my needs quite well. It is a c++ linear algebra library interfacing with lapack/blas.

On gentoo, this is what one needs:

  1. If you have intel cpu, emerge sci-libs/mkl. This is a blas/lapack drop-in replacement from Intel. You need to go to intel’s website and register (free) for a non-commercial usage license. AMD has a similar library. Otherwise, just setup your blas/lapack of choice.
  2. use eselect blas/cblas/lapack list/set to choose mkl as the blas/lapack implementation to use.
  3. now emerge sci-libs/armadillo. It is important to install it after 1) and 2) b/c it will decide what library it’s linking against during compilation time

Now, #include <armadillo> in your cpp code, and use
g++ -O3 -larmadillo your_code.cpp -o your_exe
to compile. You don’t have to use -lblas -llapack as these are already taken care of by -larmadillo (which was done in 3 above, that’s why emerge order is important).

On a Mac OS X (my office workstation), the appropriate way to compile is instead:
g++ -O3 -framework Accelerate your_code.cpp -o your_exe
as per armadillo’s readme file.

I transcribed my ruby/gsl code into c++/armadillo, and on the Mac, it actually is 2 times faster than my boss’s fortran code—since both are using the same underlying blas/lapack implementation, I suppose there’s some unnecessary computation in the fortran code. At any rate, it seems safe to say the c++ overhead is not significant so I’ll happily settle for armadillo for the moment.

Written by zsh

March 31, 2011 at 11:41 pm

Posted in /etc, gentoo

Tagged with , , , ,

TeX capacity exceeded

leave a comment »

After the discovery of gnuplot’s tikz term, I have been using it for most of the plots I send to my advisor. A very nagging problem though is that when the number of data points is big, pdflatex would complain about “TeX capacity exceeded, sorry [main memory size = xxxx]” and refuse to compile. Today it has just come to a point I can’t stand this any more, so I did some googling and found a solution. Now TeX is a very messy system with fmt, sty, cnf files all over the place, so be sure to backup anything you touch in case something goes wrong.

Here’s a web page from JadeTeX that pointed me in the right direction, http://jadetex.sourceforge.net/#index-div-d18e113. The following solution is based on this.

  1. make changes to texmf.cnf. You may want to use `locate texmf.cnf’ to find where it is. Then in it, change `main_memory’ from 3000000 to say 8000000
  2. now regenerate latex.fmt for plain latex, or pdflatex.fmt for pdflatex. E.g., to recompile pdflatex.fmt:
    1. find where “pdflatex.ini” is
    2. cd to that path, then invoke “pdflatex -ini -progname=pdflatex pdflatex.ini”
      Notice that this is different from what’s in the JadeTeX webpage. You need to invoke “pdflatex” instead of “tex”
    3. now find where the original “pdflatex.fmt” is, back it up, and copy the generated “pdflatex.fmt” to there
  3. to regenerate “latex.fmt”, use “latex -ini -progname=latex latex.ini

Update@2011/06/08:

In gentoo, the proper way of fixing this once and for all is:

  1. Change the value of the corresponding field in file /etc/texmf/texmf.d/20sizes.cnf. This should persist through all future texliveupgrades.
  2. run texmf-update to regenerate the system-wide texmf.cnf
  3. run fmtutil-sys --all to regenerate the .fmt files

Update@2012/3/15:

alternatively one can compile with lualatex, which doesn’t seem to have a size limit

Written by zsh

February 23, 2011 at 2:37 pm

firefox segfaults after zlib upgrade

leave a comment »

After some emerging, my firefox suddenly started segfaulting everytime. The worst part of a segfault is you don’t get anything useful out of it, no error message, etc. A backtrace in gdb shows the problem is from a recent upgrade of sys-libs/zlib, and google says it’s an old problem, and as usual, gentoo devs refuse to fix it (maybe for a good reason, but who cares).

Some more googling brought me to this gcc ML post. The solution is simply to add -mstackrealign into your /etc/make.conf. Re-emerge zlib then solves the problem.

Written by zsh

February 5, 2011 at 1:39 pm

migrating gentoo to a new partition

leave a comment »

quick note to myself, copy with caution..

mkfs.ext4 /dev/sda2
mount /dev/sda2 /mnt/newgentoo
cp -xavv / /mnt/newgentoo/
# -x is used b/c I have some dirs as mount points of fs on other disks
cd /mnt/newgentoo/dev
# need /dev/console and /dev/null for a successful boot
# otherwise will get an error of "unable to open an initial console"
# cf. http://www.gentoo.org/doc/en/udev-guide.xml, 3. Known issues
mknod -m 660 console c 5 1
mknod -m 660 null c 1 3

and finally, don’t forget to change /boot/grub/menu.lst and /mnt/newgentoo/etc/fstab

Written by zsh

December 5, 2010 at 8:28 pm

network printing on gentoo

leave a comment »

1. emerge cups. leave all conf files as-is

2. emerge foomatic-db-ppds, equivalently just download the ppd file corresponding to your printer (the one in my office is lexmark c543dn)

3. add yourself to the groups lp (for printing) and lpadmin (for using web interface to configure cups)

4. start cupsd (e.g., add it to the default run-level), then visit https://localhost:631

5. add printer from within the web interface. For the lexmark mentioned above, locate the corresponding ppd file installed in step 2. The network address should be socket://ip-address-of-the-printer (I googled and saw on one lexmark official page that the printer should be accessed through the port 9100, which from the cups manual should have socket:// in its URI)

6. I also queried the printer’s default printing options from within cups web interface b/c the default option used by cups doesn’t utilize the duplex feature of the printer.

7. now just use lpr -P&lt printer name &gt to print (e.g., from the gtk printing dialogue box). &lt printer name &gt is the name you used in step 5 when adding the printer.

Written by zsh

November 21, 2010 at 12:43 am

Posted in gentoo

Tagged with , , ,

misc notes on pidgin vv support

leave a comment »

pidgin 2.6.2 is out today. Supposedly it fixed the problem when a video call is initiated but only a blank window appears. But you still need the following packages for video calling to actually work:

  • to test gstreamer a/v devices, need gstreamer-properties in package gnome-extra/gnome-media
  • for v4l(2) devices (that’s your camera) to work, also need media-plugins/gst-plugins-v4l(2)

Written by zsh

September 6, 2009 at 11:07 pm

Posted in gentoo

Tagged with , , ,