Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker refine #115

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
**/*.pyc
**/__pycache__
.gitignore
.git
docker
.dockerignore
23 changes: 23 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM nvidia/cuda:10.0-cudnn7-devel-ubuntu16.04
ARG PYTHON_VERSION=3.6
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*

RUN curl -o ~/miniconda.sh -O https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
chmod +x ~/miniconda.sh && \
~/miniconda.sh -b -p /opt/conda && \
rm ~/miniconda.sh && \
/opt/conda/bin/conda install -y python=$PYTHON_VERSION && \
/opt/conda/bin/conda clean -ya
ENV PATH /opt/conda/bin:$PATH

WORKDIR /opt/texar
COPY . .
RUN pip install -e . && pip install -r requirements.txt
ENV LD_LIBRARY_PATH /usr/local/cuda-10.0/compat:$LD_LIBRARY_PATH

WORKDIR /workspace
RUN chmod -R a+w /workspace
51 changes: 51 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Docker images for Texar

## Build the docker image

If you don't have Docker, please [install docker](https://docs.docker.com/engine/installation/) first.

This Dockerfile is supplied to build docker image with Ubuntu 16.04, cuda 10.0 and cudnn v7. The image uses Miniconda to configure python environment.

### Build image with default Python3.6

By default, the Miniconda of image uses Python3.6.

The image need to be built from `texar` repo directory, because docker needs to copy `texar` repo into its filesystem to install Texar into the image. So under current directory, run the following cmds to build image with Python3.6:

```bash
cd ..
docker build -f docker/Dockerfile -t texar .
```

### Build image with other Python versions

You can pass `--build-arg PYTHON_VERSION=x.y` flag in the building cmd to specify the Python version for Miniconda. E.g. under current directory, run following cmds to build image with Python2.7:

```bash
cd ..
docker build --build-arg PYTHON_VERSION=2.7 -f docker/Dockerfile -t texar .
```

Otherwise leave it unset to use the default python3.6

## Check Texar installation

To check if Texar is installed correctly, firstly run container shell from the image, use following cmd:

```bash
docker run -it texar /bin/bash
```

Then import Texar in python, we can run the following cmd into container shell:

```bash
python -c "import texar as tx;print(tx.data)"
```

If Texar is installed correctly, the shell should return:

```bash
<module 'texar.data' from '/opt/texar/texar/data/__init__.py'>
```

To exit the container shell, press `Ctrl` + `d`.