From 7cca583c272045d2f8efc5e216bb77e6d4fa50b8 Mon Sep 17 00:00:00 2001 From: Kevin Bird Date: Mon, 17 Oct 2022 17:43:18 -0500 Subject: [PATCH 1/5] adding devcontainer environment --- .devcontainer/.env.template | 1 + .devcontainer/devcontainer.json | 32 +++++++++++++++++++ .gitignore | 1 + Dockerfile | 55 +++++++++++++++++++++++++++++++++ requirements-devcontainer.txt | 8 +++++ 5 files changed, 97 insertions(+) create mode 100644 .devcontainer/.env.template create mode 100644 .devcontainer/devcontainer.json create mode 100644 Dockerfile create mode 100644 requirements-devcontainer.txt diff --git a/.devcontainer/.env.template b/.devcontainer/.env.template new file mode 100644 index 0000000..5f13e7e --- /dev/null +++ b/.devcontainer/.env.template @@ -0,0 +1 @@ +EXAMPLE1=Testing123 \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..5e88a6d --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,32 @@ +{ + "name": "diffusion-confusion", + "build": { + "dockerfile": "../Dockerfile", + "context": ".." + }, + "containerUser": "1000", + "settings": { + "python.pythonPath": "/usr/local/bin/python", + "[python]": { + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.organizeImports": true + } + } + }, + "extensions": [ + "ms-python.python" + ], + "mounts": [ + "source=cache,target=/home/kevin/.cache,type=volume" + ], + "workspaceFolder": "/code", + "workspaceMount": "source=${localWorkspaceFolder},target=/code,type=bind,consistency=cached", + "runArgs": [ + "--ipc=host", + "--env-file=.devcontainer/.env", + "--gpus", + "all" + ], + "postCreateCommand": "jupyter notebook", +} \ No newline at end of file diff --git a/.gitignore b/.gitignore index d5a023d..bd80d73 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ sd-concept-output/ .ipynb_checkpoints/ +.env \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a368f84 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,55 @@ +FROM nvidia/cuda:11.3.1-cudnn8-runtime-ubuntu20.04 + +ARG USERNAME=kevin +ARG USER_UID=1000 +ARG USER_GID=$USER_UID +RUN apt-key adv --fetch-keys https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu2004/x86_64/3bf863cc.pub + +ENV PIP_EXTRA_INDEX_URL=https://download.pytorch.org/whl/cu116 +ENV LANG=C.UTF-8 \ + LC_ALL=C.UTF-8 \ + PATH="${PATH}:/root/.poetry/bin" + +RUN apt update -y && apt install -y sudo +RUN groupadd --gid $USER_GID $USERNAME &&\ + useradd --uid $USER_UID --gid $USER_GID -m $USERNAME &&\ + echo ${USERNAME} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USERNAME} &&\ + chmod 0440 /etc/sudoers.d/${USERNAME} + +RUN SNIPPET="export PROMPT_COMMAND='history -a' && export HISTFILE=~/.bash_history" && echo $SNIPPET >> "/home/${USERNAME}/.bashrc" + +RUN apt update -y +RUN DEBIAN_FRONTEND=noninteractive apt install -y tzdata +RUN apt install -y \ + build-essential \ + curl \ + git + +# GPU Setup +RUN apt-get install -y \ + libcairo2-dev \ + libgl1-mesa-glx \ + software-properties-common + +# Install Python 3.9 +RUN add-apt-repository ppa:deadsnakes/ppa +RUN apt install -y python3.9-dev python3.9-venv +RUN python3.9 -m ensurepip +RUN ln -s /usr/bin/python3.9 /usr/local/bin/python +RUN ln -s /usr/local/bin/pip3.9 /usr/local/bin/pip +RUN pip install --upgrade pip + +USER ${USERNAME} + +CMD mkdir -p /code +WORKDIR /code +RUN mkdir sparrow_patterns && \ + touch sparrow_patterns/__init__.py +# COPY setup.cfg . +# COPY setup.py . +COPY requirements.txt . +RUN pip install -r requirements.txt +ADD . . + + +ENTRYPOINT [ "make" ] \ No newline at end of file diff --git a/requirements-devcontainer.txt b/requirements-devcontainer.txt new file mode 100644 index 0000000..47c9704 --- /dev/null +++ b/requirements-devcontainer.txt @@ -0,0 +1,8 @@ +diffusers +transformers +fastcore +jupyter +torch +torchvision +torchaudio +matplotlib \ No newline at end of file From 3c303a843d1964be0d0814e3f61ccef82de7b4db Mon Sep 17 00:00:00 2001 From: Kevin Bird Date: Tue, 18 Oct 2022 03:51:07 -0500 Subject: [PATCH 2/5] add jupyter to requirements --- requirements-devcontainer.txt | 8 -------- requirements.txt | 1 + 2 files changed, 1 insertion(+), 8 deletions(-) delete mode 100644 requirements-devcontainer.txt diff --git a/requirements-devcontainer.txt b/requirements-devcontainer.txt deleted file mode 100644 index 47c9704..0000000 --- a/requirements-devcontainer.txt +++ /dev/null @@ -1,8 +0,0 @@ -diffusers -transformers -fastcore -jupyter -torch -torchvision -torchaudio -matplotlib \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 1ef1196..c88793b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ fastai diffusers transformers huggingface-hub +jupyter \ No newline at end of file From c6f778f5c2d0c44f84a15756a02e9f652c2c300b Mon Sep 17 00:00:00 2001 From: Kevin Bird Date: Tue, 18 Oct 2022 04:22:07 -0500 Subject: [PATCH 3/5] change username from kevin to dev --- .devcontainer/devcontainer.json | 2 +- Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 5e88a6d..c322ae8 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -18,7 +18,7 @@ "ms-python.python" ], "mounts": [ - "source=cache,target=/home/kevin/.cache,type=volume" + "source=cache,target=/home/dev/.cache,type=volume" ], "workspaceFolder": "/code", "workspaceMount": "source=${localWorkspaceFolder},target=/code,type=bind,consistency=cached", diff --git a/Dockerfile b/Dockerfile index a368f84..2d21304 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM nvidia/cuda:11.3.1-cudnn8-runtime-ubuntu20.04 -ARG USERNAME=kevin +ARG USERNAME=dev ARG USER_UID=1000 ARG USER_GID=$USER_UID RUN apt-key adv --fetch-keys https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu2004/x86_64/3bf863cc.pub From 70d30db58bd9b4aeece31403fca5300c01cf4af9 Mon Sep 17 00:00:00 2001 From: Kevin Bird Date: Tue, 18 Oct 2022 04:45:45 -0500 Subject: [PATCH 4/5] Cleaning up dockerfile a bit --- Dockerfile | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2d21304..2873693 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,9 +7,7 @@ RUN apt-key adv --fetch-keys https://developer.download.nvidia.cn/compute/cuda/r ENV PIP_EXTRA_INDEX_URL=https://download.pytorch.org/whl/cu116 ENV LANG=C.UTF-8 \ - LC_ALL=C.UTF-8 \ - PATH="${PATH}:/root/.poetry/bin" - + LC_ALL=C.UTF-8 RUN apt update -y && apt install -y sudo RUN groupadd --gid $USER_GID $USERNAME &&\ useradd --uid $USER_UID --gid $USER_GID -m $USERNAME &&\ @@ -43,13 +41,6 @@ USER ${USERNAME} CMD mkdir -p /code WORKDIR /code -RUN mkdir sparrow_patterns && \ - touch sparrow_patterns/__init__.py -# COPY setup.cfg . -# COPY setup.py . COPY requirements.txt . RUN pip install -r requirements.txt -ADD . . - - -ENTRYPOINT [ "make" ] \ No newline at end of file +ADD . . \ No newline at end of file From d0d53c25a1e8dc35159d71106c3e0e7eea6c43aa Mon Sep 17 00:00:00 2001 From: Kevin Bird Date: Tue, 1 Nov 2022 05:58:20 -0500 Subject: [PATCH 5/5] adding jupyter extensions + gistit --- .devcontainer/devcontainer.json | 2 +- Dockerfile | 4 ++++ requirements.txt | 7 ++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index c322ae8..e77cb66 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -28,5 +28,5 @@ "--gpus", "all" ], - "postCreateCommand": "jupyter notebook", + "postCreateCommand": "jq --arg GITHUB_PAT $GITHUB_PAT '.gist_it_personal_access_token = $GITHUB_PAT' ~/.jupyter/nbconfig/notebook.json > ~/.jupyter/nbconfig/notebook1.json && cp ~/.jupyter/nbconfig/notebook1.json ~/.jupyter/nbconfig/notebook.json && jupyter notebook --no-browser --NotebookApp.token='' --NotebookApp.password=''" } \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 2873693..c0d0cee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,4 +43,8 @@ CMD mkdir -p /code WORKDIR /code COPY requirements.txt . RUN pip install -r requirements.txt +RUN git config --global credential.helper store +RUN /home/dev/.local/bin/jupyter contrib nbextension install --user +RUN sudo apt install jq -y +RUN /home/dev/.local/bin/jupyter nbextension enable gist_it/main ADD . . \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index c88793b..f087e8b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,9 @@ fastai diffusers transformers huggingface-hub -jupyter \ No newline at end of file +notebook<6 +jupyter_contrib_nbextensions +nbconvert<6.2 +jinja2<3.1 +ipywidgets +opencv-python \ No newline at end of file