Skip to content

Commit

Permalink
Create devcontainer (EleutherAI#150)
Browse files Browse the repository at this point in the history
* devcontainer

* add button

* change to python 3.10
  • Loading branch information
derpyplops committed Apr 4, 2023
1 parent db3f9d5 commit 0f9ba11
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Use Nvidia Ubuntu 20 base (includes CUDA if a supported GPU is present)
# https://hub.docker.com/r/nvidia/cuda
FROM nvidia/cuda:11.6.2-cudnn8-devel-ubuntu20.04@sha256:55211df43bf393d3393559d5ab53283d4ebc3943d802b04546a24f3345825bd9

ARG USERNAME
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Create the user
# https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& usermod -a -G video user \
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME

ENV DEBIAN_FRONTEND=noninteractive

# Install dependencies
RUN apt-get update && \
apt-get -qq -y install \
software-properties-common && \
add-apt-repository ppa:deadsnakes/ppa && \
apt-get update && \
apt-get -qq -y install \
build-essential \
python3.10 \
python3.10-dev \
python3.10-distutils \
python3.10-venv \
curl \
git \
tmux

# Update package list, add the deadsnakes PPA, and install dependencies


ENV PATH="$HOME/.local/bin:$PATH"

# Install pip (we need the latest version not the standard Ubuntu version, to
# support modern wheels)
RUN sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python3.10 get-pip.py

# Set python aliases
RUN sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1
RUN sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1

# User the new user
USER $USERNAME
47 changes: 47 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "Python 3",
"build": {
"dockerfile": "Dockerfile",
"args": {
"USERNAME": "user"
}
},
"customizations": {
"vscode": {
"settings": {
"python.formatting.autopep8Path": "autopep8",
"python.linting.mypyPath": "mypy",
"terminal.integrated.defaultProfile.linux": "tmux",
"terminal.integrated.profiles.linux": {
"bash": {
"path": "bash",
"icon": "terminal-bash"
},
"tmux": {
"path": "bash",
"args": ["-c", "tmux new -ADs ${PWD##*/}"],
"icon": "terminal-tmux"
}
}
},
"extensions": [
"davidanson.vscode-markdownlint",
"donjayamanne.githistory",
"donjayamanne.python-extension-pack",
"github.vscode-pull-request-github",
"ms-python.python",
"ms-toolsai.jupyter",
"ms-vsliveshare.vsliveshare-pack",
"njpwerner.autodocstring",
"stkb.rewrap",
"streetsidesoftware.code-spell-checker",
"tushortz.python-extended-snippets",
"yzhang.markdown-all-in-one",
"elagil.pre-commit-helper",
"eamodio.gitlens"
]
}
},
"containerUser": "user",
"postCreateCommand": "pip install -e .[dev] --no-warn-script-location"
}
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ The hidden states resulting from `elk elicit` are cached as a HuggingFace datase
## Development
Use `pip install pre-commit && pre-commit install` in the root folder before your first commit.

### Devcontainer

[
![Open in Remote - Containers](
https://img.shields.io/static/v1?label=Remote%20-%20Containers&message=Open&color=blue&logo=visualstudiocode
)
](
https://vscode.dev/redirect?url=vscode:https://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/EleutherAI/elk
)

### Run tests
```bash
pytest
Expand Down

0 comments on commit 0f9ba11

Please sign in to comment.