Monday, December 14, 2015

DL4J Deep Learning for Java installation on Windows

This is purely based on http://deeplearning4j.org/ but selects the steps I followed to install DL4J on Windows. The website deeplearning4j.org provides multiple ways to do but some can be complicated. This is what I have done and it works for me. Hope this is helpful for others who want to do similar things. Please forgive my formatting ...

Java 7 or above

Java is the main interface and networking language of ND4J, because it’s used for everything from distributed cloud-based systems with thousands of nodes, to low-memory IoT devices. It’s a “write once, run anywhere” language.

If you don’t have Java 7 installed on your machine, download the Java Development Kit (JDK) here.

What I downloaded is JDK1.8.0_66. And I added JAVA_HOME as an environment variable. See following screenshots:





To test which version of Java you have (and whether you have it at all), type the following into your command line: java -version:

d:>java -version
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b18)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b18, mixed mode)

Maven

Maven is an automated build tool for Java projects (among its other uses). It locates the latest version of ND4J and DL4J project libraries (.jar files) and downloads them automatically. You can find those repositories on Maven Central.

After downloading, extract and set PATH variable.


Similar to the setting of JAVA_HOME when installing Java, here we add M2_HOME with value of C:\apache-maven-3.3.9 and M2 with value of %M2_HOME%\bin in User variables.

To check if Maven is installed in your machine, and which version you have, enter the following into the command line:
 mvn --version
What I got:

C:>mvn --version

Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T10:41:4

7-06:00)

Maven home: C:\apache-maven-3.3.9\bin\..

Java version: 1.8.0_66, vendor: Oracle Corporation

Java home: C:\Program Files\Java\jdk1.8.0_66\jre

Default locale: en_US, platform encoding: Cp1252

OS name: "windows 7", version: "6.1", arch: "amd64", family: "dos"

Integrated Development Environment: IntelliJ

An Integrated Development Environment (IDE) will allow you to work with our API and build your nets with a few clicks. The free community edition of IntelliJ has installation instructions. This is straightforward.

DL4J example

The example can be downloaded and extracted from
https://github.com/deeplearning4j/dl4j-0.4-examples
Git can be used if Git is installed.

Now open IntelliJ, choose "Import Project", navigate to D:\DL4J\dl4j-0.4-examples-master\ and select the file pom.xml. Select DBNIrisExample.java from the lefthand file tree. Hit run! (It’s the green button that appears when you right-click on the source file…)

The following shows my setting and output in IntelliJ:

To run more examples and do more experiments, it seems more tools are needed.

MinGW


Install MinGW 32 bits even if you have a 64-bit computer (the download button is on the upper right). I also installed a few other packages using the installer.

Download Lapack liblapack3.dll without Intel compiler. Also download libblas3.dll. Put the files under C:\BLAS and add this to PATH.

It seems these are sufficient for running the examples. Git can also be installed.

Checking the tools

Running this file, WindowsInfo.bat, can help debug your Windows install. Here’s one example of its output that shows what to expect. First download it, then open a command window / terminal. cd to the directory to which it was dowloaded. Enter WindowsInfo and hit enter. To copy its output, right click on command window -> select all -> hit enter. Output is then on clipboard.

Here is what I got:

d:WindowsInfo.bat
Getting data. Please Wait...
--------------------------------------------
Operating System: Microsoft Windows 7 Professional 64-bit
Service Pack: 1
Processor: Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz
GPU: Intel(R) HD Graphics 5500
Total Memory: 8080
--------------------------------------------
-- Java --
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b18)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b18, mixed mode)
Java home: C:\Program Files\Java\jdk1.8.0_66
--------------------------------------------
-- cl.exe --
INFO: Could not find files for the given pattern(s).
'cl.exe' is not recognized as an internal or external command,
operable program or batch file.
-- vcvars32.bat --
INFO: Could not find files for the given pattern(s).
-- vcvars64.bat --
INFO: Could not find files for the given pattern(s).
-- CUDA --
'nvcc' is not recognized as an internal or external command,
operable program or batch file.
-- GIT --
git version 2.6.3.windows.1
-- Maven --
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T10:41:4
7-06:00)
Maven home: C:\apache-maven-3.3.9\bin\..
Java version: 1.8.0_66, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_66\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "dos"
-- OpenBLAS --
libblas3.dll, liblapack3.dll, libopenblas.dll:
C:\blas\libblas3.dll
C:\blas\liblapack3.dll
C:\blas\libopenblas.dll
--------------------------------------------
-- PATH --
C:\ProgramData\Oracle\Java\javapath;C:\windows\system32;C:\windows;C:\windows\Sy
stem32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\W
iFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x
86)\Riverbed\Steelhead Mobile\;C:\Program Files (x86)\Skype\Phone\;C:\Program Fi
les (x86)\IVI Foundation\VISA\WinNT\Bin;C:\Program Files\Git\cmd;D:\Tools\miktex\bin\x64\;C:\apache-maven-3.3.9\bi
n;C:\blas;C:\Program Files\Git\bin

No comments:

Post a Comment