LinuxInstall

From KratosWiki
(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
== Install Kratos the easy way ==
+
== How to compile Kratos: Linux x64 ==
If you are the owner of an Ubuntu-based linux machine, then you can directly install a .deb file. Such package ( [http://kratos.cimne.upc.es/attachments/download/385/KratosMultiphysics-3.0.0.deb Download] ) automatically installs the Kratos together with all of the libraries necessary for its correct usage and leaves the
+
system ready for being used.
+
  
== Compile your own version of Kratos ==
+
In this section we are going to go through the process of compiling a basic version of Kratos Multiphysics under linux environments. Specifically we explain how to compile the linux x64 version, with the latest checked libraries. A basic knowledge of linux is assumed ( execute commands, create directories, etc...)
Developers, users of non-ubuntu machines and sudoers are expected to download and compile the source files.  
+
  
 +
Note that: Kratos linux install manuals will be always based on the last LTS version ( currently 14.04 LTS )
  
'''This tutorial assumes that a reasonably modern distribution is being used'''. Older versions may require compiling some of the files "by hand"
+
=== Subversion ===
  
One should begin by the installation of the '''prerequisites''', that is, of the libraries that are not part of the Kratos but that are needed for its compilation.
+
* Objectives:
 +
** Install subversion
 +
** Get Kratos Multiphysics source code
  
'''The installation of such prerequisites is described at [[Install Kratos Prerequisites]]. '''
+
The first thing you will need is the Kratos Multiphysics source code. To download the code you will have to use a subversion manager. You can install the default subversion by using this command:
  
 +
    $sudo apt-get install subversion
  
All of the kratos installation is based on the use of "cmake" for which a modern version is needed.
+
Once subversion is installed you can fetch the code by using this command:
  
Since "'''cmake'''" is continuosly being improved we advice the user to get and install the most modern version.
+
    $svn co https://svn.cimne.upc.edu/p/kratos/kratos
  
You can follow an installation guide here '''[[InstallCmake]].'''
+
=== Dev Packages ===
  
 +
* Objectives:
 +
** Get Python3-dev
 +
** Get Fortran compiler
 +
** Get LIBBLAS and LIBLAPACK
  
 +
You will need python dev files in order to compile kratos and some of its dependent libraries. Whether you wish to use python 3 ( recommended ) or python 2, you will need to install its dev files. This guide will show the process to install python 3.4 dev files, as is its recommended version.
  
 +
    $sudo apt-get install python3-dev
  
 +
Additionally you will need a fortran compiler, which is not present in ubuntu 14.04 by default:
  
At this point we are finally ready to install the '''Kratos'''.
+
    $sudo apt-get install gfortran
Let's assume that we are in the current user's home directory:
+
  
  $HOME/
+
We will also need an implementation of blas and lapack. You can obtain an implementation by:
  
We shall first of all get a clean version by downloading from the repository.
+
    $sudo apt-get install libblas-dev
 +
    $sudo apt-get install liblapack-dev
  
  mkdir kratos
+
Notice that some people prefer to compile solutions like ATLAS. Kratos also supports such implementations and a detailed guided can be found here.  
  cd kratos
+
  svn checkout <nowiki>https://svn.cimne.upc.edu/p/kratos/kratos</nowiki> "."
+
  
we can finally proceed to the compilation of the files. The idea is that each user can write a configuration file and activate or deactivate the
+
=== Boost ===
applications to be included.
+
  
In order to simplify the compilation an example configuration file is provided in the directory "cmake_build".
+
* Objectives:
 +
** Compile boost libraries
  
The user is expected to make a copy of the example file and to change it according to his needs
+
The next step will consist in compile Boost. Kratos Multiphysics needs Boost libraries to support some of its functions. We recommend you to use '''version 1.57'''. You can download boost from its official website:
  
  cd cmake_build
+
    http://www.boost.org/users/download/
  cp example_configure.sh.do_not_touch configure.sh
+
  
now it is possible to edit the configuration file to modify it as needed. Applications are activated by setting them to ON and deactivated by setting them to OFF.
+
Navigate to the directory where you have extracted boost and execute this command:
  
while the current configuration is designed to work "out-of-the-box" on ubuntu, on other systems one may be required to tell the cmake the position of the libraries.
+
    $sh bootstrap.sh
The file '''README''' included in the cmake_build directory attempts to cover the common cases.
+
  
Once this is done we can proceed to the compilation by doing
+
Some additional files will be generated.
 
+
  sh configure.sh
+
  
which, if completed correctly, is expected to compile the kratos and install it in the directory where it was downloaded, that is
+
By default, boost will try to link with python 2.7. '''It is important to manually specify that we want to use python 3 by adding “using python : 3.4 : /usr ;”''' to the file project-config.jam. It will look like this:
  
  $HOME/kratos
+
    # Boost.Build Configuration
 +
    # Automatically generated by bootstrap.sh
 +
   
 +
    import option ;
 +
    import feature ;
 +
   
 +
    # Compiler configuration. This definition will be used unless
 +
    # you already have defined some toolsets in your user-config.jam
 +
    # file.
 +
    if ! gcc in [ feature.values <toolset> ]
 +
    {
 +
        using gcc ;
 +
    }
 +
   
 +
    project : default-build <toolset>gcc ;
 +
   
 +
    <span style="color:red">'''# Python configuration'''</span>
 +
    <span style="color:red">'''using python : 3.4 : /usr ;'''</span>
 +
   
 +
    # List of --with-<library> and --without-<library>
 +
    # options. If left empty, all libraries will be built.
 +
    # Options specified on the command line completely
 +
    # override this variable.
 +
    libraries =  ;
 +
   
 +
    # These settings are equivalent to corresponding command-line
 +
    # options.
 +
    option.set prefix : /usr/local ;
 +
    option.set exec-prefix : /usr/local ;
 +
    option.set libdir : /usr/local/lib ;
 +
    option.set includedir : /usr/local/include ;
 +
   
 +
    # Stop on first error
 +
    option.set keep-going : false ;
  
 +
After modifying it you will have to compile the required boost libraries using this command. Notice that this will only compile “serialization” and “python” libraries. If you need further libraries, you will need to explicitly tell boost to compile them.
  
In order to be able to use the Kratos we need now to tell to the system's python installation where to find the Kratos libraries. This can be done by setting the environment variable '''PYTHONPATH''' and '''LD_LIBRARY_PATH'''
+
    $./b2 --with-python --with-serialization
  
by appending the Kratos installation directory to the existing path information by typing:
+
=== CMake ===
 
+
  echo "export PYTHONPATH=${HOME}/kratos:$PYTHONPATH" >> $HOME/.bashrc
+
  echo "export LD_LIBRARY_PATH=${HOME}/kratos/libs:$LD_LIBRARY_PATH" >> $HOME/.bashrc
+
  
The previous shell command adds one line at the end of the file '.bashrc', located in your home folder.
+
* Objectives:
 +
** Install CMake
  
Refresh the environment variables values by typing:
+
Cmake is the tool used to compile kratos. To install it simply execute this command:
  
  source ~/.bashrc
+
    $sudo apt-get install cmake
  
=== Prescribing a different installation path ===
+
=== Configure ===  
The cmake provides the possibility of prescribing a different installation path for Kratos
+
  
this can be done for example by adding the line
+
* Objectives:
  -DKRATOS_INSTALL_PREFIX="/path/to/my/kratos/installation" \
+
** Configure Kratos for the first time compilation
  -DINSTALL_PYTHON_FILES=ON \
+
 
to your "configure.sh", so to instruct to install the Kratos in the specified directory.
+
In order to compile kratos for the first time you will need to configure the project.  First, navigate to your kratos/cmake_build folder and make a copy of the template file:
 +
 
 +
    $cp example_configure.sh configure.sh
 +
 
 +
Then, open configure.sh with any text editor and modify the lines that tell cmake where some components are located.
 +
You will need to provide at least '''BOOST_ROOT''', '''PYTHON_LIBRARY''' and '''PYTHON_INCLUDE_DIR'''. It is also recommended to change '''KRATOS_INSTALL_PREFIX'''
 +
 
 +
* Option
 +
** BOOST_ROOT: Directory where you have compiled boost
 +
** PYTHON_LIBRARY: Location of the python librarie used to compile boost
 +
** PYTHON_INCLUDE_DIR: Location of the python headers
 +
** KRATOS_INSTALL_PREFIX: Sets the install directory
 +
 
 +
For example, in ubuntu it will look something like:
 +
 
 +
    -DBOOST_ROOT="~/compiled_libraries/boost_1_57_0"                                    \
 +
    -DPYTHON_LIBRARY="/usr/lib/python3.4/config-3.4m-x86_64-linux-gnu/libpython3.4m.so" \
 +
    -DPYTHON_INCLUDE_DIR="/usr/include/python3.4"
 +
 
 +
It is also recomended that you specify the directory where kratos is goin to be installed. You can do that by changing
 +
the path in '''-DKRATOS_INSTALL_PREFIX'''. If the variable is not set, the installation will be done in the source directory.
 +
 
 +
    -DKRATOS_INSTALL_PREFIX="/path/to/my/kratos/installation"                           \
 +
 
 +
Notice that you can also turn ON/OFF parts of the code according to your necessities:
 +
 
 +
    -DSTRUCTURAL_APPLICATION=<span style="color:green">'''ON'''</span>/<span style="color:red">'''OFF'''</span>                               
  
 
{{Warning|
 
{{Warning|
Line 84: Line 143:
 
}}
 
}}
  
Of course, if this is done, the PYTHONPATH environment variable should be modified accordingly (for example as)
+
=== Compile ===
   export PYTHONPATH=/path/to/my/kratos/installation/:$PYTHONPATH
+
 
 +
* Objectives:
 +
** Compile kratos.
 +
 
 +
If you followed all the steps correctly, compile kratos should be as easy as executing the configure script:
 +
 
 +
    $sh configure.sh
 +
 
 +
Please, notice that kratos is big and the compilation process can easily take 1 or 2 hours, depending on which applications are being compiled. A typical compilation process with the default configuration takes approximately 45 minutes with a i7 / 8GB Ram computer.
 +
 
 +
=== Setting up your enviroment ===
 +
 
 +
* Objectives:
 +
** Tell Linux how to execute kratos
 +
 
 +
Once Kratos ins compiled, you will have to tell the OS where to find the libraries. You can do that
 +
by executing these commands. Notice that '''you have to put the same path as in the step 5'''
 +
 
 +
   echo "export PYTHONPATH=/path/to/my/kratos/installation:$PYTHONPATH" >> $HOME/.bashrc
 +
  echo "export LD_LIBRARY_PATH=/path/to/my/kratos/installation/libs:$LD_LIBRARY_PATH" >> $HOME/.bashrc
 +
 
 +
Now each time you open a terminal these commands will be executed and the paths set automatically.
 +
If you don't want to reset your terminal the first time, just execute:
 +
 
 +
    source ~/.bashrc
 +
 
 +
=== Test ===
  
 +
* Objectives:
 +
** Tests kratos
  
=== Preparing a deb package ===
+
To to tests if everythings has gone correctly, you can execute a simple python script containing this line:
Kratos can be configured to generate deb packages. In order to do this, the
+
installation directory '''has to be set''' to "/opt/kratos" by adding
+
  -DKRATOS_INSTALL_PREFIX="/opt/kratos" \
+
  -DINSTALL_PYTHON_FILES=ON \
+
  
to our "configure.sh" configuration file.
+
    form KratosMultiphysics import *
  
The debian package is then generated by:
+
If everethung was ok you will see this message:
    make package
+
  
== Installation problems ==
+
    |  /          |           
If you have two different Python versions installed on your computer it may appear a problem. To solve it the path to Python library should be specified by adding
+
    ' /  __| _` | __|  _ \  __|
to "configure.sh" configuration file for example
+
    . \  |  (  | |  (  |\__ \
  -DPYTHON_LIBRARY="/usr/lib/python2.7/config/libpython2.7.so" \
+
    _|\_\_|  \__,_|\__|\___/ ____/
  -DPYTHON_INCLUDE_DIR="/usr/include/python2.7"
+
              Multi-Physics 3.3.11016

Revision as of 09:34, 20 November 2014

Contents

How to compile Kratos: Linux x64

In this section we are going to go through the process of compiling a basic version of Kratos Multiphysics under linux environments. Specifically we explain how to compile the linux x64 version, with the latest checked libraries. A basic knowledge of linux is assumed ( execute commands, create directories, etc...)

Note that: Kratos linux install manuals will be always based on the last LTS version ( currently 14.04 LTS )

Subversion

  • Objectives:
    • Install subversion
    • Get Kratos Multiphysics source code

The first thing you will need is the Kratos Multiphysics source code. To download the code you will have to use a subversion manager. You can install the default subversion by using this command:

   $sudo apt-get install subversion

Once subversion is installed you can fetch the code by using this command:

   $svn co https://svn.cimne.upc.edu/p/kratos/kratos

Dev Packages

  • Objectives:
    • Get Python3-dev
    • Get Fortran compiler
    • Get LIBBLAS and LIBLAPACK

You will need python dev files in order to compile kratos and some of its dependent libraries. Whether you wish to use python 3 ( recommended ) or python 2, you will need to install its dev files. This guide will show the process to install python 3.4 dev files, as is its recommended version.

   $sudo apt-get install python3-dev

Additionally you will need a fortran compiler, which is not present in ubuntu 14.04 by default:

   $sudo apt-get install gfortran

We will also need an implementation of blas and lapack. You can obtain an implementation by:

   $sudo apt-get install libblas-dev
   $sudo apt-get install liblapack-dev

Notice that some people prefer to compile solutions like ATLAS. Kratos also supports such implementations and a detailed guided can be found here.

Boost

  • Objectives:
    • Compile boost libraries

The next step will consist in compile Boost. Kratos Multiphysics needs Boost libraries to support some of its functions. We recommend you to use version 1.57. You can download boost from its official website:

   http://www.boost.org/users/download/

Navigate to the directory where you have extracted boost and execute this command:

   $sh bootstrap.sh

Some additional files will be generated.

By default, boost will try to link with python 2.7. It is important to manually specify that we want to use python 3 by adding “using python : 3.4 : /usr ;” to the file project-config.jam. It will look like this:

   # Boost.Build Configuration
   # Automatically generated by bootstrap.sh
   
   import option ;
   import feature ;
   
   # Compiler configuration. This definition will be used unless
   # you already have defined some toolsets in your user-config.jam
   # file.
   if ! gcc in [ feature.values <toolset> ]
   {
       using gcc ; 
   }
   
   project : default-build <toolset>gcc ;
   
   # Python configuration
   using python : 3.4 : /usr ;
   
   # List of --with-<library> and --without-<library>
   # options. If left empty, all libraries will be built.
   # Options specified on the command line completely
   # override this variable.
   libraries =  ;
   
   # These settings are equivalent to corresponding command-line
   # options.
   option.set prefix : /usr/local ;
   option.set exec-prefix : /usr/local ;
   option.set libdir : /usr/local/lib ;
   option.set includedir : /usr/local/include ;
   
   # Stop on first error
   option.set keep-going : false ;

After modifying it you will have to compile the required boost libraries using this command. Notice that this will only compile “serialization” and “python” libraries. If you need further libraries, you will need to explicitly tell boost to compile them.

   $./b2 --with-python --with-serialization

CMake

  • Objectives:
    • Install CMake

Cmake is the tool used to compile kratos. To install it simply execute this command:

   $sudo apt-get install cmake

Configure

  • Objectives:
    • Configure Kratos for the first time compilation

In order to compile kratos for the first time you will need to configure the project. First, navigate to your kratos/cmake_build folder and make a copy of the template file:

   $cp example_configure.sh configure.sh

Then, open configure.sh with any text editor and modify the lines that tell cmake where some components are located. You will need to provide at least BOOST_ROOT, PYTHON_LIBRARY and PYTHON_INCLUDE_DIR. It is also recommended to change KRATOS_INSTALL_PREFIX

  • Option
    • BOOST_ROOT: Directory where you have compiled boost
    • PYTHON_LIBRARY: Location of the python librarie used to compile boost
    • PYTHON_INCLUDE_DIR: Location of the python headers
    • KRATOS_INSTALL_PREFIX: Sets the install directory

For example, in ubuntu it will look something like:

   -DBOOST_ROOT="~/compiled_libraries/boost_1_57_0"                                    \
   -DPYTHON_LIBRARY="/usr/lib/python3.4/config-3.4m-x86_64-linux-gnu/libpython3.4m.so" \
   -DPYTHON_INCLUDE_DIR="/usr/include/python3.4"

It is also recomended that you specify the directory where kratos is goin to be installed. You can do that by changing the path in -DKRATOS_INSTALL_PREFIX. If the variable is not set, the installation will be done in the source directory.

   -DKRATOS_INSTALL_PREFIX="/path/to/my/kratos/installation"                           \

Notice that you can also turn ON/OFF parts of the code according to your necessities:

   -DSTRUCTURAL_APPLICATION=ON/OFF                                 

Warn_icon.gif Warning. Please, note that:

  • Cmake requires all definitions in a single line! The line concatenation character '\' therefore MUST NOT be followed by any whitespace in the same line as this would prevent the cmake from running the lines below

Compile

  • Objectives:
    • Compile kratos.

If you followed all the steps correctly, compile kratos should be as easy as executing the configure script:

   $sh configure.sh

Please, notice that kratos is big and the compilation process can easily take 1 or 2 hours, depending on which applications are being compiled. A typical compilation process with the default configuration takes approximately 45 minutes with a i7 / 8GB Ram computer.

Setting up your enviroment

  • Objectives:
    • Tell Linux how to execute kratos

Once Kratos ins compiled, you will have to tell the OS where to find the libraries. You can do that by executing these commands. Notice that you have to put the same path as in the step 5

  echo "export PYTHONPATH=/path/to/my/kratos/installation:$PYTHONPATH" >> $HOME/.bashrc
  echo "export LD_LIBRARY_PATH=/path/to/my/kratos/installation/libs:$LD_LIBRARY_PATH" >> $HOME/.bashrc

Now each time you open a terminal these commands will be executed and the paths set automatically. If you don't want to reset your terminal the first time, just execute:

   source ~/.bashrc

Test

  • Objectives:
    • Tests kratos

To to tests if everythings has gone correctly, you can execute a simple python script containing this line:

   form KratosMultiphysics import *

If everethung was ok you will see this message:

    |  /           |             
    ' /   __| _` | __|  _ \   __|
    . \  |   (   | |   (   |\__ \ 
   _|\_\_|  \__,_|\__|\___/ ____/
              Multi-Physics 3.3.11016
Personal tools
Categories