How to build ATLAS in Ubuntu(15.04)

We can build ATLAS on a ubuntu machine.

Steps

First above all, you need to do disable ‘Intel SpeedStep’ in BIOS if you use Intel CPU. Then do the following:

# cpufreq-set -g performance -c  <CPU>

For example, I did the following because I used i5 which has quad cores.

# cpufreq-set -g performance -c 0
# cpufreq-set -g performance -c 1
# cpufreq-set -g performance -c 2
# cpufreq-set -g performance -c 3

After this part, you just need to follow the following excerpt from README.Debian says:

Building Optimized Atlas Packages on your ARCH

Building your own optimized packages of Atlas is straightforward. Just get the sources of the package and its build-dependencies:

# apt-get source atlas
# apt-get build-dep atlas
# apt-get install devscripts

and type the following from the atlas source subdir:

# fakeroot debian/rules custom

it should produce a package called:

../libatlas3-base_*.deb

which is optimized for the architecture Atlas has been built on. Then install the package using dpkg -i.

Remove openblas if you want.

$ sudo apt-get purge libopenblas-{base,dev}

Check

Choose blas and lapack.

$ sudo update-alternatives --config libblas.so.3
There are 2 choices for the alternative libblas.so.3 (providing /usr/lib/libblas.so.3).

  Selection    Path                                    Priority   Status
------------------------------------------------------------
  0            /usr/lib/atlas-base/atlas/libblas.so.3   35        auto mode
* 1            /usr/lib/atlas-base/atlas/libblas.so.3   35        manual mode
  2            /usr/lib/libblas/libblas.so.3            10        manual mode

Press enter to keep the current choice[*], or type selection number: 0

$ sudo update-alternatives --config liblapack.so.3
There are 2 choices for the alternative liblapack.so.3 (providing /usr/lib/liblapack.so.3).

  Selection    Path                                      Priority   Status
------------------------------------------------------------
  0            /usr/lib/lapack/liblapack.so.3             10        auto mode
* 1            /usr/lib/atlas-base/atlas/liblapack.so.3   5         manual mode
  2            /usr/lib/lapack/liblapack.so.3             10        manual mode

Press enter to keep the current choice[*], or type selection number: 1

You can display the BLAS / LAPACK implementation used by your NumPy / SciPy / scikit-learn install with the following commands:

from numpy.distutils.system_info import get_info
print(get_info('blas_opt'))
print(get_info('lapack_opt'))

Reference

CPU Throttling

You might need to read about CPU throttling excerpt from INSTALL.txt

********** Important Install Information: CPU THROTTLING ***********
Most OSes (including Linux) now turn on CPU throttling for power management
**even if you are using a desktop**.  CPU throttling makes pretty much all
timings completely random, and so any ATLAS install will be junk.  Therefore,
before installing ATLAS, turn off CPU throttling.  For most PCs, you can
switch it off in the BIOS (eg., on my Athlon-64 machine, I can say "No" to
"Cool and Quiet" under "Power Management").  Most OSes also provide a way
to do switch off CPU throttling, but that varies from OS to OS.  Under Fedora,
at any rate, the following command seemed to work:
     /usr/bin/cpufreq-selector -g performance
On my Core2Duo, cpufreq-selector only changes the parameters of the first CPU,
regardless if which cpu you specify.  I suspect this is a bug, because on
earlier systems, the remaining CPUs were controlled via a logical link to
/sys/devices/system/cpu/cpu0/.  In this case, the only way I found to force
the second processor to also run at its peak frequency was to issue the
following as root after setting CPU0 to performance:
   cp /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor \
      /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor

For non-broken systems, you instead issue the above command with -c <#> appended
to change the performance of each core in turn.  For example, to speedup both
processors of a dual system you would issue:
     /usr/bin/cpufreq-selector -g performance -c 0
     /usr/bin/cpufreq-selector -g performance -c 1



###############################################################################
CK.D.Lee's Personal Problem & Solution for that:
CPU model name    : Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz
After following the instructions from the website, I had error message:
CPU Throttling apparently enabled!
It appears you have cpu throttling enabled, which makes timings
unreliable and an ATLAS install nonsensical. Aborting.
See ATLAS/INSTALL.txt for further information
xconfig exited with 1

Then I googled and used following command to set the cpu0-3 performance
#sudo cpufreq-set -g performance -c 0
#sudo cpufreq-set -g performance -c 1
#sudo cpufreq-set -g performance -c 2
#sudo cpufreq-set -g performance -c 3
cat /sys/devices/system/cpu/cpu{0,1,2,3}/cpufreq/scaling_governor
performance
performance
performance
performance

BUT it couldn't solve my problem... THEN this dude from stackoverflow saved my ass:

Assuming your governor is the intel_pstate (default for Intel Sandy Bridge and Ivy Bridge CPUs as of kernel 3.9). This issue is not specific to Arch, but all distros using the new Intel pstate driver for managing CPU frequency/power management. Arch linux CPU frequency scaling.


Theodore Ts’o wrote his explanation on Google+:

  • intel_pstate can be disabled at boot-time with kernel arg intel_pstate=disable
  • The problem with the ondemand governor is that it doesn’t know the specific capabilities of the CPU
  • Executing some tasks with higher frequency will consume less power than would a lower frequency taking more time e.g. arithmetic stuff, but not true for all tasks e.g. loading something from memory
  • The intel_pstate driver knows the details of the how the CPU works and it does a better job than the generic ACPI solution
  • intel_pstate offers only two governors, powersave and performance. Intel claims that the intel_pstate “powersave” is faster than the generic acpi governor with “performance”

To change back to the ACPI driver, reboot and set the kernel arg intel_pstate=disable
Then execute modprobe acpi-cpufreq and you should have the ondemand governor available.

You can make the changes permanent by editing /etc/default/grub and adding

GRUB_CMDLINE_LINUX_DEFAULT="intel_pstate=disable"

And then updating grub.cfg ala grub-mkconfig -o /boot/grub/grub.cfg

Follow the instructions for Arch kernel module loading and add the acpi-cpufreq module.

REF.:
http://unix.stackexchange.com/questions/121410/setting-cpu-governor-to-on-demand-or-conservative
https://gist.github.com/sangheestyle/ca8ef7796aefadad8773
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s