Create a gist now

Instantly share code, notes, and snippets.

@jarutis /blas.sh
Last active May 26, 2016

get native blas running with dl4j on centos 6
# install general deps
sudo yum groupinstall "Development Tools"
sudo yum install wget unzip
# install java
cd /opt/
sudo wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u60-b27/jdk-8u60-linux-x64.tar.gz"
sudo tar xzf jdk-8u60-linux-x64.tar.gz
cd /opt/jdk1.8.0_60/
sudo alternatives --install /usr/bin/java java /opt/jdk1.8.0_60/bin/java 2
sudo alternatives --config java
# get maven
mkdir ~/ini
cd ~/ini
wget http://apache.mirror.vu.lt/apache/maven/maven-3/3.3.3/binaries/apache-maven-3.3.3-bin.tar.gz
tar -xvzf apache-maven-3.3.3-bin.tar.gz
mv apache-maven-3.3.3 mvn
alias mvn=~/ini/mvn/bin/mvn
# install openblas
wget https://github.com/xianyi/OpenBLAS/zipball/master
unzip master
cd xianyi-OpenBLAS-d0c51c4/
make
sudo make install
# centos 6 ships with gcc 4.4 which does not contain libgfortran.so.3(GFORTRAN_1.4)
# we need to install newer libgfortran.so.3
cd /etc/yum.repos.d/
sudo wget http://rpm.agresearch.co.nz/agr-free.repo
cd /etc/pki/rpm-gpg/
sudo sudo wget http://rpm.agresearch.co.nz/RPM-GPG-KEY-agresearch
sudo yum install agr-devtools-libgfortran
# replace system libgfortran with newer version
sudo mv /usr/lib64/libgfortran.so.3 /usr/lib64/libgfortran.so.3_back
sudo ln -s /opt/centos/agr-devtools/root/usr/lib64/libgfortran.so.3 /usr/lib64/libgfortran.so.3
sudo ln -s /opt/centos/agr-devtools/root/usr/lib64/libquadmath.so.0 /usr/lib64/libquadmath.so.0
# if you do not want to mess with default libgfortran setting LD_LIBRARY_PATH should also work
# export LD_LIBRARY_PATH=/opt/centos/agr-devtools/root/usr/lib64/
# create libblas and liblapack links to libopenblas
sudo ln -s /opt/OpenBLAS/lib/libopenblas.so /usr/lib64/libblas.so
sudo ln -s /opt/OpenBLAS/lib/libopenblas.so /usr/lib64/libblas.so.3
sudo ln -s /opt/OpenBLAS/lib/libopenblas.so /usr/lib64/liblapack.so
sudo ln -s /opt/OpenBLAS/lib/libopenblas.so /usr/lib64/liblapack.so.3
# alternatively libblas.so.3 and liblapack.so.3 can be anywhere as long as they are included in PATH system variable
# test
cd ~/
git clone https://github.com/deeplearning4j/dl4j-0.4-examples
cd dl4j-0.4-examples
mvn package
java -Xmx2048m -cp target/deeplearning4j-examples-0.4-rc0-SNAPSHOT.jar org.deeplearning4j.examples.convolution.CNNMnistExample
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment