diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..2e89e633 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +**/*.pyc +**/__pycache__ +.gitignore +.git +docker +.dockerignore diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..1a8fca7f --- /dev/null +++ b/docker/Dockerfile @@ -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 \ No newline at end of file diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 00000000..051bef07 --- /dev/null +++ b/docker/README.md @@ -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 + +``` + +To exit the container shell, press `Ctrl` + `d`.