harvardnlp / annotated-transformer

An annotated implementation of the Transformer paper.
http://nlp.seas.harvard.edu/annotated-transformer
MIT License
5.7k stars 1.23k forks source link

dockerfile #113

Open sdelahaies opened 1 year ago

sdelahaies commented 1 year ago

Many thanks for this great work!

I couldn't find a way to install the requirements properly without complaint so I ended up using the following Dockerfile to run the notebook

FROM nvidia/cuda:11.3.1-cudnn8-devel-ubuntu20.04
# https://dockr.ly/3e57aTq

# fix (tzdata)
ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get -y update && \
    apt-get -y upgrade && \
    apt-get install -y python3-pip python3-dev

RUN apt-get install -y locales git vim nano

# requirements
COPY requirements.txt requirements.txt
RUN python3 -m pip install --upgrade pip && \
     python3 -m pip install -r requirements.txt

# Jupyter lab
RUN python3 -m pip install jupyterlab

RUN python3 -m pip install --upgrade --quiet jupyter_client ipywidgets

# run
CMD /bin/bash -c 'jupyter lab --no-browser --allow-root --ip=0.0.0.0 --NotebookApp.token="" --NotebookApp.password=""'

with the following requirements.txt file

--find-links https://download.pytorch.org/whl/torch_stable.html

pandas==1.3.5
torch==1.11.0+cu113
#torch==1.13.0+cu116
#torchdata==0.3.0
torchdata==0.3.0
torchtext==0.12
#torchtext==0.15.1
spacy==3.2.6
altair==4.2.2
jsonschema==4.3.3
jupytext==1.13
flake8
black
GPUtil
wandb
typing_extensions==4.4.0

run the following command to build the image

docker build -t transformers .

then cd to the repo folder and run the container with the command

docker run -it --gpus all -p 8888:8888 -v $PWD:/lab/ transformers

jupyterlab is available at localhost:8888 and the repo can be accessed within the container in the /lab folder.

NOTE: in the notebook for the spacy downloads replace any python with python3

rayzhou2017 commented 1 year ago

Thanks, it helps.