Skip to content

prdm0/compiling_julia

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 

Repository files navigation

Instructions for compiling Julia language with OpenBLAS (GNU/Linux)

IMPORTANT: Be sure to remove all versions of BLAS, LAPACK and OpenBLAS installed in /usr/lib and /usr/lib64.

DEPENDENCES:

  • git
  • make
  • cmake
  • gcc
  • gcc-fortran
  • patch

Important: I'll be at all times assuming that the project Julia has been cloned into the directory $HOME/Downloads. Also, I will consider the /opt directory as the installation directory for the OpenBLAS library and of the Julia language. You can choose a directory of your choice.

Compiling OpenBLAS

Initially download the Julia and OpenBLAS (Open Optimized BLAS Library) source codes in OpenBLAS. In the file directory, perform the following steps.

Note:

  1. Simply invoking make (or gmake on BSD) will detect the CPU automatically. To set a specific target CPU, use make TARGET=xxx, e.g. make TARGET=HASWELL. The full target list is in the file TargetList.txt.
  2. This will make the compilation run faster using all the features of your CPU. To know the number of cores, do: nproc. The default installation directory is /opt/OpenBLAS.
cd $HOME/Downloads
tar -zxvf OpenBLAS*
cd OpenBLAs*
make -j $(nproc) 
sudo make install PREFIX=/opt/OpenBLAS

or

cd $HOME/Downloads
git clone https://github.com/xianyi/OpenBLAS.git
cd OpenBLAS*
git checkout v0.3.5
make -j $(nproc) 
sudo make install PREFIX=/opt/OpenBLAS

Modifying the directory /opt/OpenBLAS (Soft Links)

In order for the Julia language compilation to proceed correctly with the link to the OpenBLASlibrary installed in the /opt/ directory, we have to create some soft links. The /opt/OpenBLAS/lib directory and symbolic links should be of the following form:

soft_link_julia

Some of the soft links had already been created with the library installation OpenBLAS. To create the remaining symbolic links, do the following:

cd /opt/OpenBLAS/lib
sudo ln -sf libopenblas_haswellp-r0.3.5.so libblas.so
sudo ln -sf libopenblas_haswellp-r0.3.5.so libcblas.so
sudo ln -sf libopenblas_haswellp-r0.3.5.so liblapack.so
sudo cp -a lib* /usr/lib64
sudo cp -a lib* /usr/lib

Note:

1 - Make sure that there is no installed version of blas, lapack and OpenBLAS in /usr. The command cp -a lib * will copy the compiled OpenBLAS library files along with the symbolic links created so they can be used throughout the system.

2 - Note that the libopenblas_haswellp-r0.3.5.so file may have a different name on your machine because of the version of OpenBLAS and computer architecture. Usually it has a name in the form libopenblas_xxx. If this is the case, make the necessary change in file name.

Cloning the Julia Project

Initially do the Julia project clone on GitHub. That way, with git installed and configured, do:

cd $HOME/Downloads && git clone git://github.com/JuliaLang/julia.git
cd julia

After downloading all the project files Julia cloned to the computer, go to the version you want to compile, for example the version v1.1.0. To know the versions, list all the tags of the language versions of the cloned project (git tag -l).

git checkout v1.1.0

Creating the Make.user file

Subsequently, have the OpenBLAS library in the /opt/OpenBLAS/lib/ directory be added to the environment variable LD_LIBRARY_PATH. In Linux, the LD_LIBRARY_PATH environment variable is a set of colon-separated directories where libraries should be searched first, before the default set of directories. This will cause the Julia compilation to consider the OpenBLAS library of the /opt/OpenBLAS/lib/. In the cloned directory, create the Make.user file with the following content:

cd $HOME/Downloads/julia
USE_SYSTEM_XXX=1
MARCH=native
LDFLAGS=-Wl,-rpath,/usr/lib64
LDFLAGS+=-Wl,-rpath,/usr/lib
LDFLAGS+=-Wl,-rpath,/opt/OpenBLAS/lib
OPENBLAS_DYNAMIC_ARCH=0
USE_SYSTEM_BLAS=1
USE_SYSTEM_LAPACK=1

or

cd $HOME/Downloads/julia
echo "USE_SYSTEM_XXX=1
MARCH=native
LDFLAGS=-Wl,-rpath,/usr/lib64
LDFLAGS+=-Wl,-rpath,/usr/lib
LDFLAGS+=-Wl,-rpath,/opt/OpenBLAS/lib
OPENBLAS_DYNAMIC_ARCH=0
USE_SYSTEM_BLAS=1
USE_SYSTEM_LAPACK=1" > Make.user

Note: Other paths of libraries of interest can be added to the Make.user file by doing LDFLAGS+=-Wl,-rpath,/path/of/library.

Now, under the cloned directory of Julia, under the version of interest, compile the language doing:

cd $HOME/Downloads/julia
make -j $(nproc)

echo "prefix=/opt/julia" >> Make.user
cd /opt 
sudo mkdir julia 
cd $HOME/Downloads/julia
sudo make install
sudo ln -sf /opt/julia/bin/julia /usr/bin
julia

Note: In my tests, the procedure of compiling OpenBLAS separately and later compiling the Julia language provided greater computational efficiency.

Atom Editor/IDE for Julia language

To program in Julia I recommend using the Atom programming editor. Atom, through the uber-juno plugin, can become Juno, a programming IDE for the Julia language. To use Juno, install the Atom and later, in an Atom section, simultaneously press Ctrl +,. This will cause a settings tab to open. Then click in +Install and type in the uber-juno search and install it.

Note: Since there is a soft link to Julia in /usr/bin, the atom will identify with ease, thus ensuring that we will use the version of Julia that was compiled following the previous steps.

Some advantages of Atom / Juno as IDE for programming in Julia language are:

  1. It is Open Source;
  2. A large community developing tools and improvements;
  3. It was created by the GitHub community, thus having an easy integration with the git version system;
  4. There are many easy-to-install themes;
  5. There are many useful packages for programmers.


Juno IDE for programming in Julia language

In addition to the uber-juno pugin, other useful pugins may be installed. Such plugins are listed below:

  1. "Ask Stack": Plugin to search Stack Overflow. Make Ctrl + Alt + a;
  2. "Git-Plus": Features function for git usage;
  3. "File-Icons": Add icons in the files in the tree view;

About

Instructions for compiling the Julia language using OpenBLAS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published