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..e77cb66 --- /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/dev/.cache,type=volume" + ], + "workspaceFolder": "/code", + "workspaceMount": "source=${localWorkspaceFolder},target=/code,type=bind,consistency=cached", + "runArgs": [ + "--ipc=host", + "--env-file=.devcontainer/.env", + "--gpus", + "all" + ], + "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/.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..c0d0cee --- /dev/null +++ b/Dockerfile @@ -0,0 +1,50 @@ +FROM nvidia/cuda:11.3.1-cudnn8-runtime-ubuntu20.04 + +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 + +ENV PIP_EXTRA_INDEX_URL=https://download.pytorch.org/whl/cu116 +ENV LANG=C.UTF-8 \ + 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 &&\ + 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 +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 1ef1196..f087e8b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,9 @@ fastai diffusers transformers huggingface-hub +notebook<6 +jupyter_contrib_nbextensions +nbconvert<6.2 +jinja2<3.1 +ipywidgets +opencv-python \ No newline at end of file