Skip to content

Deeplearning4j with Apple M1 Chip

Han Sheng - CertifAI edited this page Jun 17, 2021 · 1 revision

Initial Setup

  1. Open terminal information details.  

  2. Change the duplicated terminal name to Rosetta.  

  3. Right-click on Rosetta, select Get Info.  

  4. Make sure Open using Rosetta is checked to enable the Rosetta environment.  

  5. Open Rosetta Terminal and install Homebrew using command /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)". Ignore the (base) in the screenshot.  

  6. Type brew in Rosetta Terminal. You should see the output as below.  

  7. Type brew tap bell-sw/liberica in Rosetta Terminal, and you will see the output as below. Ignore the (dl4j-arm) in the screenshot.  

  8. Type brew install --cask liberica-jdk15-full in Rosetta Terminal.  

  9. Type java -version in Rosetta Terminal. You should see the output below.  

  10. Install maven using command brew install maven.  

  11. Type sudo nano ~/.zshrc, and press enter.  

  12. Paste two line below:

  • export JAVA_HOME=/Library/Java/JavaVirtualMachines/liberica-jdk-15-full.jdk/Contents/Home

  • export MAVEN_OPTS="-Xms8192m -Xmx8192m"

    at the bottom of the file. After that, press control + x, follow by press Y, and press enter.  

  1. Type mvn -version in Rosetta Terminal. The output should be same as below.  

  2. Clone CDLE Training Labs repository using git clone cd cdle-training-labs.  

  3. Type cd cdle-training-labs and type mvn clean install.  

  4. A Build Success message will shown in Rosetta Terminal once the compilation process is successful.  

Compile Java Code using Rosetta Terminal

  1. Open CDLE Training Lab repository using IntelliJ.  

  2. Wait the dependencies resolving process done.  

  3. Ignore the dependencies error in IntelliJ.  

  4. We need to identify its root folder name, package name and class name for the Java file we want to compile. Let's say we want to run CNN.java in dl4j-cv-labs.  

  5. Open the Rosetta Terminal in Application.

  6. Type cd cdle-training-labs/<root folder name>. Root folder name can be obtain in Step 4. In my case, I'll run CNN in dl4j-cv-labs.

  7. Type mvn exec:java -Dexec.mainClass=<package name>.<class name> in Rosetta Terminal and it will start compiling. Package name and class name can be obtain in Step 4. In my case I'll run CNN in dl4j-cv-labs.

Clone this wiki locally