Set primary monitor in Ubuntu

I use two monitors for my Ubuntu box. At some point, for whatever reason, the two monitors were swapped. I switched back in system settings. But it kept behaving strangely. When it boots up, the two were still swapped, and swapped back after I logged in. After logging in the mouse cursor strangely sticks to the border between the two monitors.

Later I found a tip here to set the primary monitor in Ubuntu and this fixed all problems.

Set primary monitor in Ubuntu

install the old ffmpeg on ubuntu


I copy the steps here:

sudo apt-get remove ffmpeg
sudo apt-get purge libav-tools
sudo add-apt-repository ppa:jon-severinsson/ffmpeg
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install ffmpeg
sudo apt-get install frei0r-plugins
sudo apt-get --purge auto remove
install the old ffmpeg on ubuntu

Build PTAM on Ubuntu

Install TooN

git clone toon
cd toon
./configure --prefix=$HOME
make install

Install libCVD

Install the dependency first:

sudo apt-get install libdc1394-22-dev libv4l-dev
(cd /usr/include/linux && sudo ln -s ../libv4l1-videodev.h videodev.h)
git clone libcvd
cd libcvd
CXXFLAGS=-D_REENTRANT ./configure --without-ffmpeg --prefix=$HOME
# or CXXFLAGS=-D_REENTRANT ./configure --without-ffmpeg --prefix=$HOME --disable-fast7
vi cvd_src/image_io/jpeg.cxx
# at lines 160 and 189: replace `true' with `(boolean)1'
# at line 253: replace `true' with `(boolean)1'
# at line 339: replace `1' with `(boolean)1'
make -j8
make install

Install GVars

Install the dependency:

sudo apt-get install libreadline6-dev
git clone gvars
cd gvars
./configure --disable-widgets --prefix=$HOME
make -j8
make install

Build PTAM

Build it:

git clone ptam
cd ptam
git checkout Linuxmint15
cd Src
vi Makefile
# modify the include and lib paths in the Makefile
# make depend
make -j12

Run it:

# calibrate the camera
cp camera.cfg settings.cfg
# track!


Build PTAM on Ubuntu

Multiple NVidia graphics cards in Ubuntu

Two NVidia GTX/GT graphics cards + two monitors + Intel motherboard + Ubuntu 12.04 + 64 bit Nvidia driver + CUDA installation

Disconnect the secondary one of the two monitors.

Select the primary video adaptor in BIOS setup. If the BIOS persists not to change the order, try to change it to automatic or something else, then to change it to manual with your favoured order in the next reboot.

This ensures that you have POST messages and tty1–6 consoles displayed in your primary graphics card correctly.

Update xorg.conf. nvidia-settings can do it for you. Ensure that:
you have a “Device” section which identifies correctly the graphics card you want to use for X11.
This will have your X11 server use the graphics card you want.

Install the graphics card driver in the following order.

Download the suitable graphics card driver and the CUDA toolkit in the following pages, both the .run installers.

EDIT: Check which version of gcc was used to build the kernel:

cat /proc/version

Set compiler version the same as that used to compile kernel:

sudo update-alternatives --config gcc


export CC=/usr/bin/gcc-x.x

If you’re in GUI environment, press ctrl-alt-F1 to change to a tty console.

Stop X server:

sudo service lightdm stop

Remove the old NVidia driver:

sudo apt-get remove nvidia-*

Remove the nouveau driver which causes problems with maya and potentially with other software:

sudo apt-get remove xserver-xorg-video-nouveau

If you installed the driver without using apt-get you may need:

sudo /usr/bin/nvidia-uninstall

Remove the NVidia kernel module:

sudo dkms remove -m nvidia -v <version> --all

To identify the kernel module that’s running:

lsmod | grep nvidia
find /lib/modules | grep nvidia

To get more info about the kernel module:

modinfo <module name>

nvidia apt-get uninstaller removes kernel modules, so better reboot before checking it.

Install the driver—run the downloaded graphics card driver (the .run file):

sudo sh ./NVIDIA-Linux-x86_64-<version>.run

After installing the driver, remove xorg.conf file:

sudo mv /etc/X11/xorg.conf /etc/X11/xorg.conf.backup

Set your gcc version back if you had to change it for the driver compilation:

sudo update-alternatives --config gcc


sudo reboot

Install CUDA—run the downloaded CUDA toolkit .run installer:

sudo sh ./cuda_<version>

During the installation, do not install the driver, but only the CUDA toolkit and sample code.

After the installation add path and library path.

export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

Connect the second monitor.

Failed to run `/usr/sbin/dkms add -m nvidia -v 331.20 -k 3.2.0-57-generic`: Error! DKMS tree already contains: nvidia-331.20 You cannot add the same module/version combo more than once.


Multiple NVidia graphics cards in Ubuntu

missing nvidia-settings after driver update

After the update of the driver to enable CUDA for the NVidia graphics cards of my Ubuntu box, nvidia-settings seemed to disappear. Trying to install it didn’t help as it apparently is already installed!

$ nvidia-settings
nvidia-settings: command not found
$ sudo apt-get install nvidia-settings
Reading package lists... Done
Building dependency tree
Reading state information... Done
nvidia-settings is already the newest version.
The following packages were automatically installed and are no longer required:
linux-headers-3.2.0-29 linux-headers-3.2.0-29-generic
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

It turned out that it actually is there, but the link is broken as it used to be linked to the binary in some version-specific directory. Fixing the broken link made it work now.

$ find /usr -name nvidia-settings
$ ls -l /usr/bin/nvidia-settings
lrwxrwxrwx 1 root root 33 Aug 22 12:45 /usr/bin/nvidia-settings -> /etc/alternatives/nvidia_settings
$ ls -l /etc/alternatives/nvidia_settings*
lrwxrwxrwx 1 root root 48 Aug 22 12:45 /etc/alternatives/nvidia_settings -> /usr/lib/nvidia-settings-304/bin/nvidia-settings
lrwxrwxrwx 1 root root 39 Aug 22 12:45 /etc/alternatives/nvidia_settings_conf -> /usr/lib/nvidia-settings-304/
$ sudo ln -sf /usr/lib/nvidia-settings/bin/nvidia-settings /etc/alternatives/nvidia_settings
$ sudo ln -sf /usr/lib/nvidia-settings/ /etc/alternatives/nvidia_settings_conf
$ ls -l /etc/alternatives/nvidia_settings*
lrwxrwxrwx 1 root root 44 Sep 26 16:41 /etc/alternatives/nvidia_settings -> /usr/lib/nvidia-settings/bin/nvidia-settings
lrwxrwxrwx 1 root root 35 Sep 26 16:42 /etc/alternatives/nvidia_settings_conf -> /usr/lib/nvidia-settings/
missing nvidia-settings after driver update