Skip to content

Commit

Permalink
Add a Dockerfile for the command-line interface (#1008)
Browse files Browse the repository at this point in the history
* Add a Dockerfile for the command-line interface

* Check out tag 'stable' for building the CLI in Docker

this tag points to the latest release/tagged version.

* Update README.md for Docker as per review comments

* Capitalize Python

* Fix code snippet indention in the README for Docker
  • Loading branch information
melentye authored and chivee committed Oct 31, 2017
1 parent d94ec89 commit 4adebd0
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 4 deletions.
59 changes: 55 additions & 4 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,63 @@ Follow the general installation instructions
* [OSX](https://docs.docker.com/installation/mac/): [docker toolbox](https://www.docker.com/toolbox)
* [Ubuntu](https://docs.docker.com/installation/ubuntulinux/)

## Running the Container
## Using CLI Version of LightGBM via Docker

Build the container, for python users:
Build a Docker image with LightGBM CLI:

docker build -t lightgbm -f dockerfile-python .
```
mkdir lightgbm-docker
cd lightgbm-docker
wget https://raw.githubusercontent.com/Microsoft/LightGBM/master/docker/dockerfile-cli
docker build -t lightgbm-cli -f dockerfile-cli .
```

where `lightgbm-cli` is the desired Docker image name.

Run the CLI from the container:

```
docker run --rm -it \
--volume $HOME/lgbm.conf:/lgbm.conf \
--volume $HOME/model.txt:/model.txt \
--volume $HOME/tmp:/out \
lightgbm-cli \
config=lgbm.conf
```

In the above example, three volumes are [mounted](https://docs.docker.com/engine/reference/commandline/run/#mount-volume--v-read-only)
from the host machine to the Docker container:

* `lgbm.conf` - task config, for example

```
app=multiclass
num_class=3
task=convert_model
input_model=model.txt
convert_model=/out/predict.cpp
convert_model_language=cpp
```

* `model.txt` - an input file for the task, could be training data or, in this case, a pre-trained model.
* `out` - a directory to store the output of the task, notice that `convert_model` in the task config is using it.

`config=lgbm.conf` is a command-line argument passed to the `lightgbm` executable, more arguments can
be passed if required.

## Running the Python-package Сontainer

Build the container, for Python users:

```
mkdir lightgbm-docker
cd lightgbm-docker
wget https://raw.githubusercontent.com/Microsoft/LightGBM/master/docker/dockerfile-python
docker build -t lightgbm -f dockerfile-python .
```

After build finished, run the container:

docker run --rm -it lightgbm
```
docker run --rm -it lightgbm
```
16 changes: 16 additions & 0 deletions docker/dockerfile-cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM ubuntu:16.04

RUN apt-get update && \
apt-get install -y cmake build-essential gcc g++ git && \
rm -rf /var/lib/apt/lists/*

RUN git clone --recursive --branch stable https://github.com/Microsoft/LightGBM && \
mkdir LightGBM/build && \
cd LightGBM/build && \
cmake .. && \
make -j4 && \
make install && \
cd ../.. && \
rm -rf LightGBM

ENTRYPOINT ["lightgbm"]

0 comments on commit 4adebd0

Please sign in to comment.