miike-ai commited on
Commit
d799084
·
verified ·
1 Parent(s): c5b5843

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +70 -41
Dockerfile CHANGED
@@ -1,79 +1,108 @@
1
- FROM ubuntu:22.04
2
 
3
  # Set environment variables
4
  ENV DEBIAN_FRONTEND=noninteractive
5
  ENV HOME=/root
6
- # CUDA paths for when running on GPU (RunPod)
7
  ENV CUDA_HOME=/usr/local/cuda
8
  ENV PATH=${CUDA_HOME}/bin:${PATH}
9
  ENV LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
 
10
 
11
- # Install dependencies, code-server, and Ollama
12
  RUN apt-get update && \
13
- apt-get install -y curl wget gpg apt-transport-https git software-properties-common && \
14
- # Add Python 3.12
15
- add-apt-repository ppa:deadsnakes/ppa && \
 
 
 
 
 
16
  apt-get update && \
17
- apt-get install -y python3.11 python3.11-venv python3.11-dev && \
18
- # Make Python 3.12 the default
19
- update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 && \
20
- update-alternatives --set python3 /usr/bin/python3.11 && \
21
- # Install pip for Python 3.12
22
- curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11 && \
23
- # Upgrade pip
24
- python3 -m pip install --upgrade pip setuptools wheel && \
25
- # Install Node.js 22.x from NodeSource
26
- curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
27
- apt-get install -y nodejs && \
28
- # Install code-server
29
- curl -fsSL https://code-server.dev/install.sh | sh && \
30
- apt-get clean && \
31
- rm -rf /var/lib/apt/lists/*
32
 
33
- # Install global npm packages
34
- RUN npm install -g @anthropic-ai/claude-code @anthropic-ai/dxt
 
35
 
36
- # Create a directory for the workspace
37
  RUN mkdir -p /workspace
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
- # Copy and install requirements - fail loudly if not found
40
- COPY requirements.txt /workspace/requirements.txt
41
- RUN echo "Installing Python requirements..." && \
42
- pip3 install --no-cache-dir -r /workspace/requirements.txt && \
43
- echo "Requirements installed successfully!"
 
44
 
45
- # Create configuration directory for code-server and Ollama
46
- RUN mkdir -p /root/.config/code-server /root/.ollama
47
 
48
- # Configure code-server to run on port 8443
49
- RUN echo "bind-addr: 0.0.0.0:8443\nauth: none\ncert: false" > /root/.config/code-server/config.yaml
50
 
51
- # Install Ollama after code-server is set up
 
 
 
 
 
 
 
 
 
 
 
52
  RUN curl -fsSL https://ollama.com/install.sh | sh || true
53
 
54
- # Install some useful VS Code extensions
 
 
 
 
55
  RUN code-server --install-extension ms-python.python && \
56
  code-server --install-extension ritwickdey.LiveServer && \
57
  code-server --install-extension ms-toolsai.jupyter
58
 
59
- # Create a startup script
60
  RUN echo '#!/bin/bash\n\
 
 
 
61
  # Start Ollama in the background\n\
62
  /usr/local/bin/ollama serve &\n\
63
  \n\
64
  # Give Ollama a moment to start\n\
65
  sleep 2\n\
66
  \n\
67
- # Start code-server in the foreground\n\
68
  exec code-server --disable-telemetry --bind-addr 0.0.0.0:8443 /workspace\n\
69
  ' > /start.sh && \
70
  chmod +x /start.sh
71
 
72
- # Expose ports for both services
73
  EXPOSE 8443 11434
74
 
75
- # Set the workspace as working directory
76
- WORKDIR /workspace
 
 
 
77
 
78
- # Start both services
79
  CMD ["/start.sh"]
 
1
+ FROM nvidia/cuda:12.8.0-devel-ubuntu22.04
2
 
3
  # Set environment variables
4
  ENV DEBIAN_FRONTEND=noninteractive
5
  ENV HOME=/root
 
6
  ENV CUDA_HOME=/usr/local/cuda
7
  ENV PATH=${CUDA_HOME}/bin:${PATH}
8
  ENV LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
9
+ ENV TORCH_CUDA_ARCH_LIST="12.0"
10
 
11
+ # Install system dependencies and build tools
12
  RUN apt-get update && \
13
+ apt-get install -y \
14
+ curl wget gpg apt-transport-https git software-properties-common \
15
+ build-essential cmake ninja-build \
16
+ libopenblas-dev libomp-dev \
17
+ && rm -rf /var/lib/apt/lists/*
18
+
19
+ # Install Python 3.12 (as recommended)
20
+ RUN add-apt-repository ppa:deadsnakes/ppa && \
21
  apt-get update && \
22
+ apt-get install -y python3.12 python3.12-venv python3.12-dev && \
23
+ update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1 && \
24
+ update-alternatives --set python3 /usr/bin/python3.12 && \
25
+ curl -sS https://bootstrap.pypa.io/get-pip.py | python3.12
 
 
 
 
 
 
 
 
 
 
 
26
 
27
+ # Install uv for faster dependency management
28
+ RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
29
+ echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
30
 
31
+ # Create workspace
32
  RUN mkdir -p /workspace
33
+ WORKDIR /workspace
34
+
35
+ # CRITICAL: Install in the EXACT order specified in the README
36
+ # Step 1: Create venv
37
+ RUN python3 -m venv /opt/unsloth-env
38
+ ENV PATH="/opt/unsloth-env/bin:$PATH"
39
+
40
+ # Step 2: Install vllm with cu128 (MUST be first)
41
+ RUN /opt/unsloth-env/bin/pip install --upgrade pip setuptools wheel && \
42
+ /opt/unsloth-env/bin/pip install -U vllm --extra-index-url https://wheels.vllm.ai/nightly
43
+
44
+ # Step 3: Install unsloth dependencies
45
+ RUN /opt/unsloth-env/bin/pip install unsloth unsloth_zoo bitsandbytes
46
 
47
+ # Step 4: Build xformers from source (no Blackwell wheels exist yet)
48
+ RUN git clone --depth=1 https://github.com/facebookresearch/xformers --recursive /tmp/xformers && \
49
+ cd /tmp/xformers && \
50
+ /opt/unsloth-env/bin/pip uninstall -y xformers && \
51
+ /opt/unsloth-env/bin/python setup.py install && \
52
+ rm -rf /tmp/xformers
53
 
54
+ # Step 5: Update triton to >=3.3.1 for Blackwell
55
+ RUN /opt/unsloth-env/bin/pip install -U "triton>=3.3.1"
56
 
57
+ # Step 6: Pin transformers to avoid gradient checkpointing bug
58
+ RUN /opt/unsloth-env/bin/pip install -U "transformers==4.52.4"
59
 
60
+ # Step 7: Might need to downgrade numpy
61
+ RUN /opt/unsloth-env/bin/pip install "numpy<=2.2"
62
+
63
+ # Now install your dev tools (code-server, Node.js, etc)
64
+ RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
65
+ apt-get install -y nodejs && \
66
+ curl -fsSL https://code-server.dev/install.sh | sh && \
67
+ npm install -g @anthropic-ai/claude-code @anthropic-ai/dxt && \
68
+ apt-get clean && \
69
+ rm -rf /var/lib/apt/lists/*
70
+
71
+ # Install Ollama
72
  RUN curl -fsSL https://ollama.com/install.sh | sh || true
73
 
74
+ # Configure code-server
75
+ RUN mkdir -p /root/.config/code-server /root/.ollama && \
76
+ echo "bind-addr: 0.0.0.0:8443\nauth: none\ncert: false" > /root/.config/code-server/config.yaml
77
+
78
+ # Install VS Code extensions
79
  RUN code-server --install-extension ms-python.python && \
80
  code-server --install-extension ritwickdey.LiveServer && \
81
  code-server --install-extension ms-toolsai.jupyter
82
 
83
+ # Create startup script with proper env activation
84
  RUN echo '#!/bin/bash\n\
85
+ # Activate the unsloth environment\n\
86
+ source /opt/unsloth-env/bin/activate\n\
87
+ \n\
88
  # Start Ollama in the background\n\
89
  /usr/local/bin/ollama serve &\n\
90
  \n\
91
  # Give Ollama a moment to start\n\
92
  sleep 2\n\
93
  \n\
94
+ # Start code-server with the activated environment\n\
95
  exec code-server --disable-telemetry --bind-addr 0.0.0.0:8443 /workspace\n\
96
  ' > /start.sh && \
97
  chmod +x /start.sh
98
 
99
+ # Expose ports
100
  EXPOSE 8443 11434
101
 
102
+ # Copy any user requirements AFTER base installation
103
+ COPY requirements.txt* /workspace/
104
+ RUN if [ -f /workspace/requirements.txt ]; then \
105
+ /opt/unsloth-env/bin/pip install -r /workspace/requirements.txt; \
106
+ fi
107
 
 
108
  CMD ["/start.sh"]