euler314 commited on
Commit
709a4c6
·
verified ·
1 Parent(s): 2244d56

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +7 -15
Dockerfile CHANGED
@@ -6,32 +6,24 @@ WORKDIR /app
6
  RUN apt-get update && apt-get install -y \
7
  build-essential \
8
  python3-dev \
9
- libeigen3-dev \
10
- python3-pybind11 \
11
  && rm -rf /var/lib/apt/lists/*
12
 
13
- # Copy files
14
  COPY requirements.txt .
15
  RUN pip install --no-cache-dir -r requirements.txt
16
 
17
  # Copy C++ source and app
18
  COPY cubic_cpp.cpp app.py ./
19
 
20
- # Get Python and pybind11 include paths directly
21
- RUN PYTHON_INCLUDE_PATH=$(python3 -c "import sysconfig; print(sysconfig.get_path('include'))") && \
22
- PYBIND11_INCLUDE_PATH=$(python3 -c "import pybind11; print(pybind11.get_include())") && \
23
- NUMPY_INCLUDE_PATH=$(python3 -c "import numpy; print(numpy.get_include())") && \
24
- # Compile the C++ module directly to a shared library
25
- g++ -O3 -Wall -shared -std=c++11 -fPIC \
26
  $(python3-config --includes) \
27
- -I${PYBIND11_INCLUDE_PATH} \
28
- -I${NUMPY_INCLUDE_PATH} \
29
  cubic_cpp.cpp \
30
  -o cubic_cpp$(python3-config --extension-suffix) && \
31
- # Verify the module was created
32
- ls -la && \
33
- # Test the import
34
- python3 -c "import cubic_cpp; print('C++ module imported successfully')"
35
 
36
  # Run the application
37
  CMD ["streamlit", "run", "app.py"]
 
6
  RUN apt-get update && apt-get install -y \
7
  build-essential \
8
  python3-dev \
 
 
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
+ # Copy requirements and install Python dependencies
12
  COPY requirements.txt .
13
  RUN pip install --no-cache-dir -r requirements.txt
14
 
15
  # Copy C++ source and app
16
  COPY cubic_cpp.cpp app.py ./
17
 
18
+ # Compile the C++ module directly with optimizations
19
+ RUN g++ -O3 -march=native -flto -ffast-math -Wall -shared -std=c++11 -fPIC \
 
 
 
 
20
  $(python3-config --includes) \
21
+ -I$(python3 -c "import pybind11; print(pybind11.get_include())") \
22
+ -I$(python3 -c "import numpy; print(numpy.get_include())") \
23
  cubic_cpp.cpp \
24
  -o cubic_cpp$(python3-config --extension-suffix) && \
25
+ # Test the import
26
+ python3 -c "import cubic_cpp; print('C++ module successfully compiled and imported')"
 
 
27
 
28
  # Run the application
29
  CMD ["streamlit", "run", "app.py"]