Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simple Dockerfile for rurnning mlx #390

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM python:3.12-slim

RUN apt-get update && apt-get install -y \
software-properties-common \
build-essential \
pkg-config \
cmake \
libopenblas-dev \
liblapack-dev \
liblapacke-dev \
python3-pip \
curl \
git

RUN git clone https://github.com/ml-explore/mlx.git && cd mlx && mkdir -p build && cd build && \
cmake .. \
-DCMAKE_PREFIX_PATH="/usr/lib/aarch64-linux-gnu" \
-DLAPACK_LIBRARIES="/usr/lib/aarch64-linux-gnu/liblapack.so" \
-DBLAS_LIBRARIES="/usr/lib/aarch64-linux-gnu/libopenblas.so" \
-DLAPACK_INCLUDE_DIRS="/usr/include" && \
sed -i 's/option(MLX_BUILD_METAL "Build metal backend" ON)/option(MLX_BUILD_METAL "Build metal backend" OFF)/' ../CMakeLists.txt && \
make -j && \
make install && \
cd .. && \
pip install --no-cache-dir .

COPY setup.py .
COPY exo ./exo

RUN sed -i '/mlx==/d' setup.py && \
pip install --no-cache-dir .

RUN pip install --no-cache-dir --no-deps mlx-lm==0.18.2

CMD ["exo", "--inference-engine", "mlx"]
36 changes: 36 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: '3.8'

services:
exo_1:
build:
context: .
environment:
- PYTHONUNBUFFERED=1
# mem_limit: 8G
# mem_reservation: 4G
ports:
- "8001:8000" # ChatGPT API port - changed to avoid conflict
volumes:
- ~/.cache/huggingface:/root/.cache/huggingface # Cache HF models
command: ["exo", "--inference-engine", "mlx", "--disable-tui"]
networks:
- exo_network

exo_2:
build:
context: .
environment:
- PYTHONUNBUFFERED=1
# mem_limit: 8G
# mem_reservation: 4G
ports:
- "8002:8000" # ChatGPT API port - changed to avoid conflict
volumes:
- ~/.cache/huggingface:/root/.cache/huggingface # Cache HF models
command: ["exo", "--inference-engine", "mlx", "--disable-tui"]
networks:
- exo_network

networks:
exo_network:
driver: bridge
1 change: 0 additions & 1 deletion exo/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import asyncio
import signal
import json
import logging
import time
import traceback
import uuid
Expand Down
27 changes: 27 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import mlx.core as mx
import numpy as np

# Create some test arrays
a = mx.array([[1, 2, 3], [4, 5, 6]], dtype=mx.float32)
b = mx.array([[7, 8, 9], [10, 11, 12]], dtype=mx.float32)

# Test basic operations
print("Array a:")
print(a)
print("\nArray b:")
print(b)

# Test multiplication
c = mx.multiply(a, b)
print("\nElement-wise multiplication (a * b):")
print(c)

# Test matrix multiplication
d = a @ b.transpose()
print("\nMatrix multiplication (a @ b.T):")
print(d)

# Test converting to numpy
print("\nConvert to numpy array:")
numpy_array = np.array(c)
print(numpy_array)