-
Notifications
You must be signed in to change notification settings - Fork 133
Installation
sudo apt-get install libatlas-base-dev
sudo apt-get --purge remove liblapack-dev liblapack3 liblapack3gf
export CPLUS_INCLUDE_PATH=/usr/include/atlas
export C_INCLUDE_PATH=/usr/include/atlas
gem install nmatrix # or "sudo gem install nmatrix" if you have a system-wide ruby
The order here can make a difference if you have libraries that depend on liblapack installed (e.g. R or numpy). We install the atlas packages first because they will typically satisfy the dependencies of these packages. The environment variables are critical for compilation, but you only need them present during compilation.
If you are getting compile or runtime errors, you may want verify that you have no lapack libraries installed. Just run the following command (may need to install aptitude "sudo apt-get install aptitude"):
# this command should return *NOTHING*! Uninstall any packages it may return
aptitude search lapack | grep '^i'
Explanation: If you have the liblapack or liblapack-dev packages installed then your compilation (or runtime) will fail because Ubuntu gives preference to clapack.h or the associated .so from liblapack and it doesn't have all the functions necessary for nmatrix to function. So, if you get an error related to clapack_dgetrf, then it's probably because you still have liblapack installed (both the dev and binary need to be uninstalled)!
Follow these instructions. Additional notes:
- You should be inside the outputatlas directory when you run the big configure command.
- 'make install' will fail, so you will need to manually copy over the lib files and make softlinks as directed in link.
- Make sure to adjust your CPLUS_INCLUDE_PATH and C_INCLUDE_PATH accordingly for compilation of nmatrix.
- Make sure you do not have liblapack deb packages installed, as discussed above.
Assuming you have ATLAS installed (and no lapack packages) as shown above:
git clone https://github.com/SciRuby/nmatrix.git
# or "git clone [email protected]:SciRuby/nmatrix.git" if you have push privileges
cd nmatrix
gem install bundler # if you don't already have it
bundle install
export CPLUS_INCLUDE_PATH=/usr/include/atlas # or wherever your atlas .h files are
export C_INCLUDE_PATH=/usr/include/atlas # or wherever your atlas .h files are
bundle exec rake compile # 'clobber' or 'clean' also useful # expect lots of warnings
bundle exec rake spec # ... => 561 examples, 3 failures, 26 pending
bundle exec ruby -I lib -S irb # to play around interactively
Validated on ruby 2.0.0-p195 and 1.9.3-p429, 2013-08-08 for nmatrix v0.0.5-37-g0651c75
The above instructions should work without fail. If they don't, email me and I'll update them for the current Ubuntu version and current nmatrix.
Advice that has been helpful in the past:
- Some errors may be squelched by setting your locale: LANG="en_US" gem install nmatrix
- If you have compile link head error, please check the libcblas.so, libatlas.so and cblas.h atlas.h file with apt-file tool:
apt-file search xxx.h
Then ln -s
with proper path.
Follow the instructions below from 10.7.4, with the following alterations:
-
Alter the gcc version in the
scripts/mac-brew-gcc.sh
from4.7.1
to4.7.2
-
Change the last uncommented line in the script from
make install
tosudo make install
- you will need to enter your password when prompted -
When gcc is installed, you will need to symlink differently:
sudo ln -nfs /usr/gcc-4.7.2/bin/gcc-4.7.2 /usr/bin/gcc
sudo ln -nfs /usr/gcc-4.7.2/bin/g++-4.7.2 /usr/bin/g++
-
You will need to recompile ruby with the new gcc - this is very important!
-
If you are using
ruby-build
orrbenv-install
and you have an error recompiling ruby with the new compiler, check this issue, you can workaround by commenting out the following lines in the ruby-build script:
if type clang &>/dev/null; then
if "${CC:-clang}" -x c /dev/null -E -Wno-error=shorten-64-to-32 &>/dev/null; then
RUBY_CFLAGS="$RUBY_CFLAGS -Wno-error=shorten-64-to-32"
fi
fi
Now it should install fine!
Download Xcode from the App Store and run Install Xcode. Run Xcode and open its Preferences pane. Go to the Downloads tab and install Command Line Tools.
You will need Homebrew. Make sure everything's OK with brew doctor
.
Check your version of GCC:
gcc -v
If it's less than 4.3, you need to upgrade. First, check the path to the Xcode directory:
xcode-select -print-path
Check if that directory exists. If not, you will need to run something like:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
Otherwise, you will see the following error when compiling:
Error: No developer directory found at /Developer. Run /usr/bin/xcode-select to update the developer directory path.
You can now install a newer GCC using this script that's part of NMatrix, or use Homebrew below:
brew install https://raw.github.com/Homebrew/homebrew-dupes/master/gcc.rb
/usr/bin/gcc
and /usr/bin/g++
should be symlinks. Point them to the newer version:
sudo ln -nfs /usr/local/bin/gcc-4.7 /usr/bin/gcc
sudo ln -nfs /usr/local/bin/g++-4.7 /usr/bin/g++
Clean up any previous attempts to compile:
rake clean
We want to include cblas.h
but not clapack.h
. Both are in /System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Versions/Current/Headers/
, so we can't just set C_INCLUDE_PATH
and CPLUS_INCLUDE_PATH
. Instead, create a symlink:
sudo ln -s /System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Versions/Current/Headers/cblas.h /usr/include/cblas.h
Unset environment variables, in case you had previously set them:
unset C_INCLUDE_PATH
unset CPLUS_INCLUDE_PATH
Now you can compile NMatrix:
git clone https://github.com/SciRuby/nmatrix.git
cd nmatrix
bundle
bundle exec rake compile
If that worked, you can install it (N
is the current version number):
bundle exec rake repackage
gem install pkg/nmatrix-0.0.N.gem
If you receive an error similar to the following when trying to require
the library:
$ irb
> require 'nmatrix'
LoadError: dlopen(...):
Symbol not found: _clapack_cgetrf
Try to install the gem with the option --with-lapacklib
:
gem install pkg/nmatrix-0.0.N.gem -- --with-lapacklib
See #34 if you have any issues.