Skip to content

Instantly share code, notes, and snippets.

@mirosval
Created September 27, 2016 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mirosval/4413439c8dc42bcd645cfefa3b8d0da7 to your computer and use it in GitHub Desktop.
Save mirosval/4413439c8dc42bcd645cfefa3b8d0da7 to your computer and use it in GitHub Desktop.
Tensorflow Javacpp-presets Linux Build

Check out javacpp and javacpp-presets into a directory, place the Dockerfile next to them, and then run:

> docker build -t javacpp-presets .
> docker cp $(docker ps -aq | head -n 1):/javacpp-presets/tensorflow/target/tensorflow-linux-x86_64.jar tensorflow-linux-x86_64.jar
FROM centos:7
RUN yum install epel-release -y && \
yum install -y \
clang \
gcc-c++ \
gcc-gfortran \
java-devel \
maven \
python \
numpy \
swig \
git \
file \
which \
wget \
zip \
unzip \
tar \
bzip2 \
gzip \
xz \
patch \
make \
cmake \
perl \
nasm \
yasm \
atlas-devel \
openblas-devel \
freeglut-devel \
gtk2-devel \
libusb-devel \
libusb1-devel \
zlib-devel \
libjpeg-devel && \
yum install -y `rpm -qa | sed s/.x86_64$/.i686/`
RUN yum remove -y java-1.7.0-openjdk && \
cd /opt/ && \
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/8u101-b13/jdk-8u101-linux-x64.tar.gz" && \
tar xzf jdk-8u101-linux-x64.tar.gz
# RUN cd /opt/jdk1.8.0_101/
RUN alternatives --install /usr/bin/java java /opt/jdk1.8.0_101/bin/java 2
# RUN alternatives --config java 2
RUN alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_101/bin/jar 2
RUN alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_101/bin/javac 2
RUN alternatives --set jar /opt/jdk1.8.0_101/bin/jar
RUN alternatives --set javac /opt/jdk1.8.0_101/bin/javac
ENV JAVA_HOME=/opt/jdk1.8.0_101
ENV JRE_HOME=/opt/jdk1.8.0_101/jre
ENV PATH="$PATH:/opt/jdk1.8.0_101/bin:/opt/jdk1.8.0_101/jre/bin:/maven/apache-maven-3.3.9/bin"
RUN mkdir /maven && cd /maven && \
wget http://mirror2.shellbot.com/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz && \
tar xzf apache-maven-3.3.9-bin.tar.gz
RUN git clone --depth 1 https://github.com/bazelbuild/bazel.git
RUN cd bazel && ./compile.sh && cp /bazel/output/bazel /bin/bazel
COPY javacpp /javacpp
RUN cd /javacpp && \
mvn clean install
COPY javacpp-presets /javacpp-presets
RUN cd /javacpp-presets && \
bash cppbuild.sh -platform linux-x86_64 install tensorflow
RUN cd /javacpp-presets && \
mvn clean install --projects .,tensorflow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment