In order to get you up and running for hands-on learning experience, we need to set you up with an environment for running Python, Jupyter notebooks, the relevant libraries, and the code needed to run the book itself.
Installing JDK 11 (not jre)¶
JDK 11 (or above) are required to run the examples provided in this folder.
To confirm the java path is configured properly, run:
java --list-modules | grep "jdk.jshell" > firstname.lastname@example.org
Install jupyter notebook on python3¶
Use the following command to install Jupyter Notebook in Python 3:
pip3 install jupyter
Install Java kernel for jupyter notebook¶
By default jupyter notebook runs only Python3. You need to install the Java kernel to run Java code such as DJL.
git clone https://github.com/frankfliu/IJava.git cd IJava/ ./gradlew installKernel
Downloading the D2L-Java Notebooks¶
Next, we need to download the code for this book. You can clone our repository and browse all the notebooks using Jupyter Notebook.
git clone https://github.com/aws-samples/d2l-java cd d2l-java
Running Jupyter Notebook¶
Once the above dependencies are installed, we can now open the Jupyter notebook by running:
At this point, you can open http://localhost:8888 (it usually opens automatically) in your Web browser. Then we can run the code for each section of the book. Remember to switch the Kernel to Java instead of Python3.
Adding the dependencies on DJL and the MXNet engine¶
You can add maven dependencies on DJL and MXNet by adding a Java cell including:
// Add the maven dependencies %maven ai.djl:api:0.7.0-SNAPSHOT %maven org.slf4j:slf4j-api:1.7.26 %maven org.slf4j:slf4j-simple:1.7.26 // See https://github.com/awslabs/djl/blob/master/mxnet/mxnet-engine/README.md // for more MXNet library selection options %maven ai.djl.mxnet:mxnet-native-auto:1.7.0-b
Now you can import and run different modules in DJL.
We recommend using the “ai.djl.mxnet:mxnet-native-auto” dependency. When you include this, DJL will detect your operating system and whether you have a GPU available. It will automatically download the corresponding MXNet GPU native libraries for your environment. No specific requirement needed to run the notebook on GPU machines. To use specific builds of MXNet engine, please refer to our documentation.
Download the code for the book and install the runtime environment.