From 2fde4a921553e15a94f97f5b7093e639b62858f0 Mon Sep 17 00:00:00 2001 From: Matt Mazzola Date: Mon, 30 Oct 2023 17:44:34 +0000 Subject: [PATCH] Add .devcontainer --- .devcontainer/Dockerfile | 53 ++++++++++++++++++++++ .devcontainer/devcontainer.env | 3 ++ .devcontainer/devcontainer.json | 73 ++++++++++++++++++++++++++++++ .devcontainer/postCreateCommand.sh | 45 ++++++++++++++++++ .editorconfig | 18 ++++++++ .gitattributes | 29 ++++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 11 +++++ .gitignore | 6 +++ .vscode/launch.json | 22 +++++++++ 9 files changed, 260 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.env create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/postCreateCommand.sh create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .vscode/launch.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 000000000..035e14937 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,53 @@ +FROM mcr.microsoft.com/devcontainers/base:ubuntu-20.04 + +SHELL [ "bash", "-c" ] + +# update apt and install packages +RUN apt update && \ + apt install -yq \ + ffmpeg \ + dkms \ + build-essential + +# add user tools +RUN sudo apt install -yq \ + jq \ + jp \ + tree \ + tldr + +# add git-lfs and install +RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash && \ + sudo apt-get install -yq git-lfs && \ + git lfs install + +############################################ +# Setup user +############################################ + +USER vscode + +# install azcopy, a tool to copy to/from blob storage +# for more info: https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-blobs-upload#upload-a-file +RUN cd /tmp && \ + wget https://azcopyvnext.azureedge.net/release20230123/azcopy_linux_amd64_10.17.0.tar.gz && \ + tar xvf azcopy_linux_amd64_10.17.0.tar.gz && \ + mkdir -p ~/.local/bin && \ + mv azcopy_linux_amd64_10.17.0/azcopy ~/.local/bin && \ + chmod +x ~/.local/bin/azcopy && \ + rm -rf azcopy_linux_amd64* + +# Setup conda +RUN cd /tmp && \ + wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \ + bash ./Miniconda3-latest-Linux-x86_64.sh -b && \ + rm ./Miniconda3-latest-Linux-x86_64.sh + +# Install dotnet +RUN cd /tmp && \ + wget https://dot.net/v1/dotnet-install.sh && \ + chmod +x dotnet-install.sh && \ + ./dotnet-install.sh --channel 7.0 && \ + ./dotnet-install.sh --channel 3.1 && \ + rm ./dotnet-install.sh + diff --git a/.devcontainer/devcontainer.env b/.devcontainer/devcontainer.env new file mode 100644 index 000000000..416860a13 --- /dev/null +++ b/.devcontainer/devcontainer.env @@ -0,0 +1,3 @@ +# Efficient AI +EFFICIENT_AI_SUBSCRIPTION_NAME="Efficient AI" +EFFICIENT_AI_SUBSCRIPTION_ID=332431bf-68bf-46f9-ab8b-c7bfe2197219 \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..ef18b7d3a --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,73 @@ +{ + "name": "LLaVA", + "build": { + "dockerfile": "Dockerfile", + "context": "..", + "args": {} + }, + "features": { + "ghcr.io/devcontainers/features/docker-in-docker:2": {}, + "ghcr.io/devcontainers/features/azure-cli:1": {}, + "ghcr.io/azure/azure-dev/azd:0": {}, + "ghcr.io/devcontainers/features/powershell:1": {}, + // "ghcr.io/devcontainers/features/common-utils:2": {}, + // "ghcr.io/devcontainers-contrib/features/zsh-plugins:0": { + // "omzPlugins": "https://github.com/zsh-users/zsh-autosuggestions", + // }, + }, + // "forwardPorts": [], + "postCreateCommand": "bash ./.devcontainer/postCreateCommand.sh", + "customizations": { + "vscode": { + "settings": { + "python.analysis.autoImportCompletions": true, + "python.analysis.autoImportUserSymbols": true, + "python.defaultInterpreterPath": "~/miniconda3/envs/llava/bin/python", + "python.formatting.provider": "yapf", + "python.linting.enabled": true, + "python.linting.flake8Enabled": true, + "isort.check": true, + "dev.containers.copyGitConfig": true, + "terminal.integrated.defaultProfile.linux": "zsh", + "terminal.integrated.profiles.linux": { + "zsh": { + "path": "/usr/bin/zsh" + }, + } + }, + "extensions": [ + "aaron-bond.better-comments", + "eamodio.gitlens", + "EditorConfig.EditorConfig", + "foxundermoon.shell-format", + "GitHub.copilot-chat", + "GitHub.copilot-labs", + "GitHub.copilot", + "lehoanganh298.json-lines-viewer", + "mhutchie.git-graph", + "ms-azuretools.vscode-docker", + "ms-dotnettools.dotnet-interactive-vscode", + "ms-python.flake8", + "ms-python.isort", + "ms-python.python", + "ms-python.vscode-pylance", + "njpwerner.autodocstring", + "redhat.vscode-yaml", + "stkb.rewrap", + "yzhang.markdown-all-in-one", + ] + } + }, + "mounts": [], + "runArgs": [ + "--gpus", + "all", + // "--ipc", + // "host", + "--ulimit", + "memlock=-1", + "--env-file", + ".devcontainer/devcontainer.env" + ], + // "remoteUser": "root" +} diff --git a/.devcontainer/postCreateCommand.sh b/.devcontainer/postCreateCommand.sh new file mode 100644 index 000000000..b32449207 --- /dev/null +++ b/.devcontainer/postCreateCommand.sh @@ -0,0 +1,45 @@ +git config --global safe.directory '*' +git config --global core.editor "code --wait" +git config --global pager.branch false + +# Set AZCOPY concurrency to auto +echo "export AZCOPY_CONCURRENCY_VALUE=AUTO" >> ~/.zshrc +echo "export AZCOPY_CONCURRENCY_VALUE=AUTO" >> ~/.bashrc + +# Activate conda by default +echo ". /home/vscode/miniconda3/bin/activate" >> ~/.zshrc +echo ". /home/vscode/miniconda3/bin/activate" >> ~/.bashrc + +# Use llava environment by default +echo "conda activate llava" >> ~/.zshrc +echo "conda activate llava" >> ~/.bashrc + +# Add dotnet to PATH +echo 'export PATH="$PATH:$HOME/.dotnet"' >> ~/.bashrc +echo 'export PATH="$PATH:$HOME/.dotnet"' >> ~/.zshrc + +# Create and activate llava environment +source /home/vscode/miniconda3/bin/activate +conda create -y -q -n llava python=3.10 +conda activate llava + +# Install Nvidia Cuda Compiler +conda install -y -c nvidia cuda-compiler + +pip install pre-commit==3.0.2 + +# Install package locally +pip install --upgrade pip # enable PEP 660 support +pip install -e . + +# Install additional packages for training +pip install -e ".[train]" +pip install flash-attn --no-build-isolation + +# Download checkpoints to location outside of the repo +git clone https://huggingface.co/liuhaotian/llava-v1.5-7b ~/llava-v1.5-7b + +# Commented because it is unlikely for users to have enough local GPU memory to load the model +# git clone https://huggingface.co/liuhaotian/llava-v1.5-13b ~/llava-v1.5-13b + +echo "postCreateCommand.sh COMPLETE!" diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..d99a490be --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +charset = utf-8 + +# 4 space indentation +[*.{py,json}] +indent_style = space +indent_size = 4 + +# 2 space indentation +[*.{md,sh,yaml,yml}] +indent_style = space +indent_size = 2 \ No newline at end of file diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..5462cde72 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,29 @@ +# https://git-scm.com/docs/gitattributes + +# Set the default behavior, in case people don't have core.autocrlf set. +# https://git-scm.com/docs/gitattributes#_end_of_line_conversion +* text=auto + +# common python attributes, taken from https://github.com/alexkaratarakis/gitattributes/blob/710900479a2bedeec7003d381719521ffbb18bf8/Python.gitattributes +# Source files +# ============ +*.pxd text diff=python +*.py text diff=python +*.py3 text diff=python +*.pyw text diff=python +*.pyx text diff=python +*.pyz text diff=python +*.pyi text diff=python + +# Binary files +# ============ +*.db binary +*.p binary +*.pkl binary +*.pickle binary +*.pyc binary export-ignore +*.pyo binary export-ignore +*.pyd binary + +# Jupyter notebook +*.ipynb text eol=lf diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..b979a924f --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,11 @@ +# Issue + + + +# Solution + + + +## Video or Screenshots + + diff --git a/.gitignore b/.gitignore index 161541239..6ff6a3dc8 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,9 @@ ckpts* .ipynb_checkpoints *.ipynb + +# DevContainer +!.devcontainer/* + +# Demo +serve_images/ diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..21b387b81 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,22 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python: llava.serve.cli", + "type": "python", + "request": "launch", + "module": "llava.serve.cli", + "justMyCode": true, + "args": [ + "--model-path", + "/workspaces/LLaVA/llava-v1.5-7b", + "--image-file", + "https://llava-vl.github.io/static/images/view.jpg", + "--load-4bit" + ] + } + ] +}