How to use Intel MKL instead of libopenblas in Julia - julia

I would like to know if there is a way i can use Intel MKL library instead of OpenBlas. I have installed MKL. Below is the version info
Julia Version 0.6.0
Commit 903644385b (2017-06-19 13:05 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin13.4.0)
CPU: Intel(R) Core(TM) i7-4770HQ CPU # 2.20GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
Kindly let me know if this can be done

This is the procedure I have used to install Julia (0.6.0) with Intel MKL (compiling from source) in macOS Sierra. Remember to uninstall previous versions of Julia first.
Install Xcode.
Launch a Terminal and update the command line tools:
$ xcode-select --install
Install Homebrew.
Use Homebrew to install gfortran:
$ brew install gfortran
Take advantage of Homebrew and install also wget:
$ brew install wget
Go to the Intel Performance Libraries webpage, register yourself and download these free libraries for OS X and install them (as with a regular DMG package):
Intel Threading Building Blocks (TBB)
Intel Math Kernel Library (MKL)
Download the Julia source (Tarball with dependencies):
$ wget https://github.com/JuliaLang/julia/releases/download/v0.6.0/julia-0.6.0-full.tar.gz
Uncompress the file and move the folder to your $HOME directory.
Launch a Terminal and change to the Julia source directory:
$ cd ~/julia-0.6.0
With your preferred tool, edit the file Make.inc and enable the use of Intel MKL and Intel MKL FFT. Save and close the file. Use the picture as a guide:
Set up the Intel MKL environment, for Intel64 architecture with 8 bytes integer support (ILP64):
$ source /opt/intel/mkl/bin/mklvars.sh intel64 ilp64
Compile Julia:
$ make
If there is a problem compiling Julia, create a symbolic link in the Julia's lib folder to the Intel MKL library and run make again:
$ ln -s /opt/intel/mkl/lib/libmkl_rt.dylib usr/lib/libmkl_rt.dylib
$ make
I did not try to run make install because I do not have Administrator privileges in my Mac, but you are free to do it. Anyway, you can run Julia from this folder:
$ ./julia
Next time you open a Terminal probably your Intel MKL variables would have gone. Just add these lines to your ~/.bash_profile:
# Intel MKL
source /opt/intel/mkl/bin/mklvars.sh intel64 ilp64

Yes this is possible but much easier to do if you are happy to re-install a clean version of julia.
You will need to edit the Make.user file as described here: https://github.com/JuliaLang/julia#intel-compilers-and-math-kernel-library-mkl

Related

Trouble installing R from homebrew formula (Intel Mac Pro)

I'm having trouble installing R from a homebrew formula on our Intel garbage can mac pro at work. I was having trouble installing tidyverse from source code so I removed and have been attempting to reinstalling R, as I thought it might have been a version mismatch somewhere.
I used
brew install R
and after a bunch of output where it's downloading other packages, I get back the following
==> Installing dependencies for r: libpng, freetype, fontconfig, gettext, libffi, pcre, glib, pkg-config, libpthread-stubs, xorgproto, libxau, libxdmcp, libxcb, libx11, libxext, libxrender, lzo, pixman, cairo, gmp, isl, mpfr, libmpc, lz4, xz, zstd, gcc, jpeg-turbo, openblas, pcre2, readline, ca-certificates, openssl#1.1 and tcl-tk
==> Installing r dependency: libpng
Unknown option: -C
usage: git [--version] [--help] [-c name=value]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
<command> [<args>]
Error: Command failed with exit 129: git
Is this in fact a git error? What is the -C command?
Things I've tried:
removing and reinstalling command line tools
removing and reinstalling Homebrew
My machine:
Mac Pro (Late 2013)
2.7 GHz 12-Core Xeon E5
Thanks!
Sam
I think it tries to use an old version of git at /usr/bin/git, but you need to run brew install git to install a newer version of git to /usr/local/bin/git.
If /usr/local/bin/ isn't on your PATH before /usr/bin/, then you can add a line like this to ~/.bash_profile:
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
However /usr/local/bin is included in /etc/paths by default, so it should be added to PATH by programs that run path_helper (like Terminal and iTerm 2 but not Script Editor or Emacs.app).

Linking brew installed openblas to /usr/local

I have installed R that in turns installs openblas - but not to /usr/local :
==> openblas
openblas is keg-only, which means it was not symlinked into /usr/local,
because macOS provides BLAS and LAPACK in the Accelerate framework.
For compilers to find openblas you may need to set:
export LDFLAGS="-L/usr/local/opt/openblas/lib"
export CPPFLAGS="-I/usr/local/opt/openblas/include"
For pkg-config to find openblas you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/openblas/lib/pkgconfig"
My primary use case for openblas is with R and scipy. The latter _no longer supports the Macos Accelerate package`: so there's no problem with redirecting to brew. The former will be using the brew anyways: so I see no harm in doing this. But how to do it?
Two steps made this work:
Uninstall openblas via brew:
brew uninstall --ignore-dependencies openblas
Reinstall R
brew install R
Manually create symbolic link to /usr/local :
sudo ln -s /usr/local/opt/openblas /usr/local
Now we have R !
$R
R version 3.6.1 (2019-07-05) -- "Action of the Toes"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin18.6.0 (64-bit)
..
>

NVIDIA OpenCL on Trusty or Mint 17

I am having a really hard time getting OpenCL working in Trusty or Mint 17. Im using ppa:xorg-edgers, tried updates and even nvidia-340.
sudo apt-get install nvidia-331 nvidia-331-uvm nvidia-cuda-toolkit nvidia-cuda-dev opencl-headers nvidia-opencl-dev clinfo
Rebooting and then
babak#ASUS-G750JH:~$ clinfo
clinfo: /usr/lib/x86_64-linux-gnu/libOpenCL.so.1: no version information available (required by clinfo)
I: ICD loader reports no usable platforms
I have tried this on two Intel based systems with Nvidia GPU's a desktop with a GeForce 280, and a laptop with GeForce 780M with a physically disabled Optimus by the Asus, it only has the Nvidia GPU. A G750JH.
Has anyone done this successfully? Can I roll back and remove the PPA and use the default repo's, would that even make a difference?
For the xorg-edgers nvidia-346 packages, I get it working by installing also the nvidia-opencl-icd-346 package and its dependency ocl-icd-libopencl1.
Im not 100% sure what the issue was, but seems that the ppa:xorg-edgers, may have an issue. Whatever is broken the process below fixes the issue and results in both Cuda and OpenCL working with Nvidia and Ubuntu 14.04 x64
sudo apt-get install dkms linux-headers-generic fakeroot build-essential
sudo apt-get remove --purge nvidia-*
sudo apt-get purge nvidia*
sudo ./NVIDIA-Linux-x86_64-346.47.run
Downloaded from Nvidia, 340.xx supports legacy cards
Yes for all options
sudo reboot chmod +x cuda-repo-ubuntu1404_6.5-14_amd64.deb
dpkg -i cuda-repo-ubuntu1404_6.5-14_amd64.deb
chmod +x cuda_6.5.14_linux_64.run sudo ./cuda_6.5.14_linux_64.run
Choose option to leave out the GPU Driver
sudo apt-get update
sudo apt-get install cuda
add to bottom of bashrc
export CUDA_HOME=/usr/local/cuda-6.5
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64
export GLPATH=/usr/lib/
PATH=${CUDA_HOME}/bin:${PATH}
export PATH
sudo reboot
./ocore_601_OpenCL_v20 --devices
Downloaded from http://stanford.edu/~yutongz/ocores/
Outputs:
OpenCL compatible devices:
name: GeForce GTX 780M | platformId: 0 deviceId: 0
cd ~/NVIDIA_CUDA-6.5_Samples/1_Utilities/deviceQuery
make
./deviceQuery
./deviceQuery Starting...
CUDA Device Query (Runtime API) version (CUDART static linking)
Detected 1 CUDA Capable device(s)
Device 0: "GeForce GTX 780M"
......
Truncated

OpenCL compile on linux

I'm a newbie in OpenCL.
From yesterday, I'm trying to use OpenCL for parallel programming instead of CUDA which is more familiar for me and experienced before.
Now I have NVIDIA GTX 580 GPU, Ubuntu Linux 12.04 OS and CUDA SDK 4.1 (already installed before because of CUDA programming).
In CUDA SDK folder, Some OpenCL header file and library are already included.
So I just downloaded OpenCL examples from NVIDIA's Developer zone.
(Here is the link! https://developer.nvidia.com/opencl)
And I'm tried to compile some example by myself, but I couldn't.
I make Makefile by using -I I added path of header file, but I don't know how to added library path and what is the name of OpenCL library.
I searched on Google but someone said file named libOpenCL.so, but I only have OpenCL.lib.
Is Someone can help me?
Install
The following steps have been tested on Ubuntu 12.04.
Download the Intel SDK for Linux.
Extract the RPM:
$ tar zxvf intel_sdk_for_ocl_applications_2012_x64.tgz
Convert to .deb and install:
$ fakeroot alien --to-deb intel_ocl_sdk_2012_x64.rpm
$ sudo dpkg -i intel-ocl-sdk_2.0-31361_amd64.deb
Ensure that libOpenCL.so has been installed to /usr/lib/.
$ sudo ln -s /usr/lib64/libOpenCL.so /usr/lib/libOpenCL.so
$ sudo ldconfig
Compile
Simply link to the OpenCL library during compilation:
$ g++ main.cpp -lOpenCL
$ ./a.out

Is there a way to get the CLISP compiled with dynamic FFI support on Mac OS?

I use clisp 2.48 (2009-07-28) on Mac OS X 10.6.4. I downloaded the clisp with 'sudo port install clisp'.
After installing quick lisp, I installed some packages, and most of them are OK.
However, when I tried to install "sqlite", I got the following error.
[1]> (ql:quickload "sqlite")
To load "sqlite":
Load 1 ASDF system:
sqlite
; Loading "sqlite"
[package cffi-sys]
*** - CFFI requires CLISP compiled with dynamic FFI support.
It says that my clisp installed with mac port doesn't have FFI support.
Is there any way to get the CLISP compiled with dynamic FFI support on Mac OS X?
I'm on 10.4, so I had to also install ffcall - I don't know if you installed it already. When installing clisp I added +dynffi to the end and it worked for me.
sudo port install ffcall
sudo port install clisp +dynffi

Resources