Awesome Open Source
Awesome Open Source

DL4J NLP examples NLP using DL4J License

This area in the repo is a result of the blog post Applying NLP in Java, all from the command-line | Original post. Please refer to the post before considering using this repo to understand better on how to use the different aspects of it.

Open built-in Terminal from the IntelliJ IDEA. If you prefer, use the terminal app on your computer. In the terminal window, cd to the project root directory dl4j-nlp-cuda-example if not already in. (you can use IDE's run-configuration green run button, if you like.)

Quick startup

    $ git clone [url to this repo]
    $ cd dl4j-nlp-cuda-example
  • create a Valohai project using the Valohai CLI tool, and give it a name
    $ vh project create
    $ vh project open
    ### Go to the Settings page > Repository tab and update the git repo address with this git repo:
  • update Valohai project with the latest commits from the git repo
    $ vh project fetch

And you are ready to start using the power of performing Machine Learning tasks from the command-line.

Advanced installation and setup

To be able to run the apps and tasks we will cover in this project on your local machine (in addition to using the Valohai platform) we would need to have the below installed and configured on your local machine (how to do each one of these are outside the scope of the project, although links to resources are provided):

Build and run app on local machine

Build and run app inside a docker container

  • Docker CE 19.03.2 or higher

Do the above and make use of GPUs - CUDA, cuDNN, etc.

  • Nvidia, CUDA 10.1 and cuDNN (7.0) drivers version (Linux and Windows machines only, support for MacOS is unavailable) (see Resources at the bottom of this post for download and installation details on GPUs, CUDA, cuDNN, etc...)

Valohai CLI installation and Valohai project setup

See Valohai CLI installation and Valohai project setup

Build the app using the Valohai platform

See Build the app using the Valohai platform

Gathering Nvidia GPU, Nvidia drivers, CUDA details

$ vh exec run know-your-gpus

Will run a bunch of commands to gather Nvidia GPU, Nvidia drivers, CUDA details on a machine, this step is also used by other steps. The captured result is stored in a log file and archive after each run. See GPU related resources

Build the app on the local machine

CPU version
$ BACKEND=cpu ./
GPU version

Note: please ensure you have access to an Nvidia GPU and the necessary drivers i.e. CUDA, cuDNN etc... are installed, see GPU related resources.

$ BACKEND=gpu ./

Run the app on the local machine

See Run the app on the local machine

Building the docker container to run CUDA-enabled Java apps

See Building the docker container to run CUDA-enabled Java apps

Run app in docker container

$ cd dl4j-nlp-cuda-example/docker
$ ./docker-runner --runContainer   ### neomatrix369 or DOCKER_USER_NAME is set to your Docker Hub username 


$ ./docker-runner --dockerUserName [neomatrix369 or your Docker Hub username] \

At the prompt in the container, do the same as mentioned in section Run app on your local machine.

You would use your Docker Hub username only when you have an Docker image with your username available locally or on Docker Hub.

Running other examples on the local machine

See Running other examples on the local machine


This example has been inspired by the DL4J NLP examples: nlp | convolution: sentence classifier | recurrent: character | recurrent: process news | recurrent: word2vec and sentiment analysis examples from DL4J. Credits to the original authors of this example on


Original authors of this DL4J example project remain the license holders of the work, although the original work has been modified to a good extent, and the Apache 2.0 License is cited for all those file/files in the matter (see License.txt in the root of the project). Exception to the above: four bash scripts have been authored by Mani Sarkar and have been cited under the Apache 2.0 license.


Return to Awesome AI/ML/DL

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Java (698,605
Machine Learning (31,898
Deep Learning (23,829
Nlp (8,431
Natural Language Processing (4,777
Cuda (3,977
Docker Container (1,347
Jvm (1,083
Nvidia (582
Cudnn (106
Nvidia Gpu (99
Deeplearning4j (69
Dl4j (34
Nvidia Driver (23
Valohai Platform (3
Cuda Details (2
Valohai Cli (2
Related Projects