Skip to content

Commit 6a7dc1f

Browse files
loujaybeeLou Bichard
and
Lou Bichard
authored
fix: add jupyter notebooks (#2)
Co-authored-by: Lou Bichard <[email protected]>
1 parent 80795a7 commit 6a7dc1f

File tree

6 files changed

+183
-9
lines changed

6 files changed

+183
-9
lines changed

.devcontainer/Dockerfile

+22-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,22 @@
1-
FROM mcr.microsoft.com/vscode/devcontainers/base:ubuntu
1+
FROM mcr.microsoft.com/vscode/devcontainers/base:ubuntu
2+
3+
# Install Ollama
4+
RUN curl -fsSL https://ollama.com/install.sh | TERM=xterm sh
5+
6+
# Install Python 3.10
7+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
8+
&& apt-get -y install python3.10 python3.10-venv python3-pip
9+
10+
# Create and activate virtual environment with Python 3.10
11+
RUN python3.10 -m venv /workspace/venv
12+
ENV PATH="/workspace/venv/bin:$PATH"
13+
14+
# Set working directory
15+
WORKDIR /workspace
16+
17+
# Install IPython kernel and its dependencies
18+
RUN pip install ipykernel && \
19+
python -m ipykernel install --user --name python3 --display-name "Python 3.10.12"
20+
21+
# Note: requirements.txt will be installed after container creation
22+
CMD [ -f "requirements.txt" ] && pip install -r requirements.txt || echo "No requirements.txt found"

.devcontainer/devcontainer.json

+16-2
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,19 @@
1313
"workspaceFolder": "/workspace",
1414
"features": {
1515
"ghcr.io/devcontainers/features/nvidia-cuda:1": {}
16-
}
17-
}
16+
},
17+
"customizations": {
18+
"vscode": {
19+
"extensions": [
20+
"ms-python.python",
21+
"ms-toolsai.jupyter"
22+
],
23+
"settings": {
24+
"python.defaultInterpreterPath": "/usr/bin/python3",
25+
"python.formatting.provider": "black",
26+
"jupyter.notebookFileRoot": "${workspaceFolder}"
27+
}
28+
}
29+
},
30+
"postCreateCommand": "pip install -r requirements.txt"
31+
}

.gitpod/automations.yaml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
services:
2+
ollama-server:
3+
name: ollama-server
4+
description: "Start ollama server"
5+
triggeredBy:
6+
- manual
7+
- postEnvironmentStart
8+
commands:
9+
start: |
10+
cd /workspace/
11+
ollama serve
12+
13+
gpu-stats:
14+
name: gpu-stats
15+
description: "GPU stats"
16+
triggeredBy:
17+
- manual
18+
commands:
19+
start: |
20+
watch -n 1 nvidia-smi
21+
22+
tasks:
23+
run-llm:
24+
name: Run LLM
25+
description: "Start the PHI:3 model"
26+
triggeredBy:
27+
- postEnvironmentStart
28+
- manual
29+
command: |
30+
sleep 60s # Hack to wait for ollama to start
31+
cd /workspace/
32+
ollama run phi3:medium

README.md

+49-6
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,32 @@ As a data scientist or ML engineer, you've likely faced the challenge of limited
1212

1313
## What's Included
1414

15-
- `.devcontainer/` - Complete GPU-enabled development environment configuration
16-
- `devcontainer.json` - Environment setup with NVIDIA CUDA support
17-
- `Dockerfile` - Base container configuration using Ubuntu
15+
- `devcontainer.json` - Decalarative and repeatable environment setup including:
16+
- NVIDIA CUDA support via features
17+
- GPU requirements and access configuration
18+
- VS Code Python and Jupyter extensions
19+
- Python interpreter and formatting settings
20+
- Automatic requirements.txt installation
21+
- Kernel specification for Jupyter notebooks
22+
- `Dockerfile` - Base container configuration using Ubuntu with CUDA toolkit and Python packages, including:
23+
- Python 3.10 with virtual environment
24+
- IPython kernel for Jupyter notebooks
25+
- Ollama for LLM inference
26+
- `requirements.txt` - All Python dependencies installed including (but not limited to):
27+
- NumPy (>=1.24.0)
28+
- Pandas (>=2.0.0)
29+
- Matplotlib (>=3.7.0)
30+
- Seaborn (>=0.12.0)
31+
- scikit-learn (>=1.3.0)
32+
- Jupyter (>=1.0.0)
33+
- IPython Kernel (>=6.0.0)
34+
- Plotly (>=5.0.0)
35+
- Plotly Express (>=0.4.0)
36+
- nbformat (>=5.0.0)
37+
- `.gitpod/automations.yaml` - Gitpod automation examples
38+
- Starting the ollama server
39+
- Seeing GPU stats of the environment
40+
- Running Ollama LLM
1841

1942
## Quick Start
2043

@@ -32,15 +55,32 @@ As a data scientist or ML engineer, you've likely faced the challenge of limited
3255
- CUDA Toolkit
3356
- Python 3.x
3457
- Common ML libraries (PyTorch, TensorFlow)
58+
- Ollama for local inference
3559

36-
## Verify Your Setup
60+
## Try It Out
3761

38-
Once your environment is running:
62+
Once your environment is running, here are some things you can try:
3963

64+
1. Run local inference with ollama:
65+
```bash
66+
ollama run phi3:medium
67+
```
68+
69+
2. See nvidia GPU performance and stats:
4070
```bash
4171
watch -n 1 nvidia-smi
4272
```
4373

74+
3. Run a Jupyter notebook:
75+
```bash
76+
jupyter notebook
77+
```
78+
79+
4. Execute a Python script:
80+
```bash
81+
python my_script.py
82+
```
83+
4484
## Customization
4585

4686
- Modify `.devcontainer/devcontainer.json` to change GPU requirements
@@ -54,7 +94,10 @@ watch -n 1 nvidia-smi
5494

5595
**Note:** Refer to AWS documentation for precise costs.
5696

57-
## Learn More
97+
## Documentation
98+
99+
For a full tutorial, check out: [https://www.gitpod.io/blog/gpu-dev-environments-on-aws](https://www.gitpod.io/blog/gpu-dev-environments-on-aws)
58100

101+
Other helpful resources:
59102
- [Gitpod Documentation](https://www.gitpod.io/docs)
60103
- [Dev Container Specification](https://containers.dev)

notebook.ipynb

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"import plotly.graph_objects as go\n",
10+
"import plotly.express as px\n",
11+
"import pandas as pd\n",
12+
"df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv')\n",
13+
"\n",
14+
"fig = go.Figure([go.Scatter(x=df['Date'], y=df['AAPL.High'])])\n",
15+
"fig.show()"
16+
]
17+
},
18+
{
19+
"cell_type": "code",
20+
"execution_count": null,
21+
"metadata": {},
22+
"outputs": [],
23+
"source": [
24+
"df = px.data.stocks(indexed=True)-1\n",
25+
"fig = px.area(df, facet_col=\"company\", facet_col_wrap=2)\n",
26+
"fig.show()"
27+
]
28+
},
29+
{
30+
"cell_type": "code",
31+
"execution_count": null,
32+
"metadata": {},
33+
"outputs": [],
34+
"source": [
35+
"df = px.data.stocks()\n",
36+
"fig = px.line(df, x=\"date\", y=df.columns,\n",
37+
" hover_data={\"date\": \"|%B %d, %Y\"},\n",
38+
" title='custom tick labels')\n",
39+
"fig.update_xaxes(\n",
40+
" dtick=\"M1\",\n",
41+
" tickformat=\"%b\\n%Y\")\n",
42+
"fig.show()"
43+
]
44+
}
45+
],
46+
"metadata": {
47+
"language_info": {
48+
"name": "python"
49+
},
50+
"orig_nbformat": 4
51+
},
52+
"nbformat": 4,
53+
"nbformat_minor": 2
54+
}

requirements.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
numpy>=1.24.0
2+
pandas>=2.0.0
3+
matplotlib>=3.7.0
4+
seaborn>=0.12.0
5+
scikit-learn>=1.3.0
6+
jupyter>=1.0.0
7+
ipykernel>=6.0.0
8+
plotly>=5.0.0
9+
plotly-express>=0.4.0
10+
nbformat>=5.0.0

0 commit comments

Comments
 (0)