From 9d88f4e6addd48991c685154762c40a9f1f9c13d Mon Sep 17 00:00:00 2001 From: Sarah Gross Date: Fri, 26 Jun 2020 18:06:18 +0200 Subject: [PATCH] Add Dockerfile; update Readme for Docker instructions; standardize pulse.yml for all platforms --- Dockerfile | 32 +++++++++++++++ README.md | 14 ++++++- pulse.yml | 112 ++++++++++++++++++++++++++--------------------------- 3 files changed, 100 insertions(+), 58 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f6633d8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +# Use nvidia docker image as base image to have GPU support +FROM nvidia/cuda:10.2-runtime +# /!\ the cuda version depends on your computer. Adapt the above line correspondingly. + +ARG NAME=pulse +# Install ubuntu libraries +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y python3-pip python3-dev \ + libz-dev libopenblas-dev libatlas-base-dev libgtk-3-dev \ + libboost-filesystem-dev build-essential cmake pkg-config curl && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Install conda +ENV PATH /opt/conda/bin:$PATH +RUN curl 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh' > ~/miniconda.sh && \ + /bin/bash ~/miniconda.sh -b -p /opt/conda && \ + rm ~/miniconda.sh && \ + /opt/conda/bin/conda clean -tipsy && \ + ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \ + echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \ + echo "conda activate base" >> ~/.bashrc +ENV PATH /opt/conda/envs/gpuenvs/bin:$PATH + +WORKDIR /home/${NAME} + +# Install the python dependencies +COPY . . +RUN conda update -n base -c defaults conda +RUN conda env create -f pulse.yml + +CMD /bin/bash \ No newline at end of file diff --git a/README.md b/README.md index e3b0ecd..c09c797 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,9 @@ Given a low-resolution input image, PULSE searches the outputs of a generative m The main file of interest for applying PULSE is `run.py`. A full list of arguments with descriptions can be found in that file; here we describe those relevant to getting started. -### Prereqs +### Installation + +#### Manually You will need to install cmake first (required for dlib, which is used for face alignment). Currently the code only works with CUDA installed (and therefore requires an appropriate GPU) and has been tested on Linux and Windows. For the full set of required Python packages, create a Conda environment from the provided YAML, e.g. @@ -58,7 +60,15 @@ dependencies ``` Finally, you will need an internet connection the first time you run the code as it will automatically download the relevant pretrained model from Google Drive (if it has already been downloaded, it will use the local copy). In the event that the public Google Drive is out of capacity, add the files to your own Google Drive instead; get the share URL and replace the ID in the https://drive.google.com/uc?=ID links in ```align_face.py``` and ```PULSE.py``` with the new file ids from the share URL given by your own Drive file. - + +#### Using Docker + 1. [Install Docker](https://docs.docker.com/get-docker/) + 2. Verify the content of `Dockerfile` in the repo, update the first line `FROM nvidia/cuda:10.2-runtime` according to the Cuda version on your computer. + 3. From the repo folder, execute `docker build -t pulse:latest .` + 4. All the times you need to run the pulse code: + * From the repo folder, execute `docker run -it --rm --gpus all --name pulse --entrypoint bash -v "$PWD:/home/pulse" pulse:latest`. The "-v" synchronizes your local folder "pulse" to "/home/pulse" in the docker so that you can easily have your tests pictures ("inputs" or "realpics") inside the docker. You might need to change `--gpus all` by `--runtime=nvidia` if your Docker version is older. + * Once you are in the docker container, activate the python env `conda activate pulse` + * Run pulse as usual (see following sections) ### Data diff --git a/pulse.yml b/pulse.yml index c82ddc6..62e71e2 100644 --- a/pulse.yml +++ b/pulse.yml @@ -2,62 +2,62 @@ name: pulse channels: - pytorch - defaults + - conda-forge dependencies: - - blas=1.0=mkl - - ca-certificates=2020.1.1=0 - - certifi=2020.4.5.1=py38_0 - - cffi=1.14.0=py38hc512035_1 - - chardet=3.0.4=py38_1003 - - cryptography=2.9.2=py38ha12b0ac_0 - - cycler=0.10.0=py38_0 - - freetype=2.9.1=hb4e5f40_0 - - idna=2.9=py_1 - - intel-openmp=2019.4=233 - - jpeg=9b=he5867d9_2 - - kiwisolver=1.2.0=py38h04f5b5a_0 + - blas=1.0 + - ca-certificates=2020.1.1 + - certifi=2020.4.5.1 + - cffi=1.14.0 + - chardet=3.0.4 + - cryptography=2.9.2 + - cycler=0.10.0 + - freetype=2.9.1 + - idna=2.9 + - intel-openmp=2019.4 + - jpeg=9b + - kiwisolver=1.2.0 - libcxx=10.0.0=1 - - libedit=3.1.20181209=hb402a30_0 - - libffi=3.3=h0a44026_1 - - libgfortran=3.0.1=h93005f0_2 - - libpng=1.6.37=ha441bb4_0 - - libtiff=4.1.0=hcb84e12_0 - - matplotlib=3.1.3=py38_0 - - matplotlib-base=3.1.3=py38h9aa3819_0 - - mkl=2019.4=233 - - mkl-service=2.3.0=py38hfbe908c_0 - - mkl_fft=1.0.15=py38h5e564d8_0 - - mkl_random=1.1.0=py38h6440ff4_0 - - ncurses=6.2=h0a44026_1 - - ninja=1.9.0=py38h04f5b5a_0 - - numpy=1.18.1=py38h7241aed_0 - - numpy-base=1.18.1=py38h6575580_1 - - olefile=0.46=py_0 - - openssl=1.1.1g=h1de35cc_0 - - pandas=1.0.3=py38h6c726b0_0 - - pillow=7.1.2=py38h4655f20_0 - - pip=20.0.2=py38_3 - - pycparser=2.20=py_0 - - pyopenssl=19.1.0=py38_0 - - pyparsing=2.4.7=py_0 - - pysocks=1.7.1=py38_0 - - python=3.8.2=hf48f09d_13 - - python-dateutil=2.8.1=py_0 - - pytorch=1.5.0=py3.8_0 - - pytz=2020.1=py_0 - - readline=8.0=h1de35cc_0 - - requests=2.23.0=py38_0 - - scipy=1.4.1=py38h44e99c9_0 - - setuptools=46.2.0=py38_0 - - six=1.14.0=py38_0 - - sqlite=3.31.1=h5c1f38d_1 - - tk=8.6.8=ha441bb4_0 - - torchvision=0.6.0=py38_cpu - - tornado=6.0.4=py38h1de35cc_1 - - urllib3=1.25.8=py38_0 - - wheel=0.34.2=py38_0 - - xz=5.2.5=h1de35cc_0 - - zlib=1.2.11=h1de35cc_3 - - zstd=1.3.7=h5bba6e5_0 + - libedit=3.1.20181209 + - libffi=3.3 + - libgfortran + - libpng=1.6.37 + - libtiff=4.1.0 + - matplotlib=3.1.3 + - matplotlib-base=3.1.3 + - mkl=2019.4 + - mkl-service=2.3.0 + - mkl_fft=1.0.15 + - mkl_random=1.1.0 + - ncurses=6.2 + - ninja=1.9.0 + - numpy=1.18.1 + - numpy-base=1.18.1 + - olefile=0.46 + - openssl=1.1.1g + - pandas=1.0.3 + - pillow=7.1.2 + - pip=20.0.2 + - pycparser=2.20 + - pyopenssl=19.1.0 + - pyparsing=2.4.7 + - pysocks=1.7.1 + - python=3.8.2 + - python-dateutil=2.8.1 + - pytorch=1.5.0 + - pytz=2020.1 + - readline=8.0 + - requests=2.23.0 + - scipy=1.4.1 + - setuptools=46.2.0 + - six=1.14.0 + - sqlite=3.31.1 + - tk=8.6.8 + - torchvision=0.6.0 + - tornado=6.0.4 + - urllib3=1.25.8 + - wheel=0.34.2 + - xz=5.2.5 + - zlib=1.2.11 + - zstd=1.3.7 - pip: - - dlib==19.19.0 -prefix: /Users/sachit/opt/miniconda3/envs/pulse + - dlib==19.19.0 \ No newline at end of file