elungky commited on
Commit
0287daf
·
1 Parent(s): 3fb78ac

Merged remote changes and resolved conflicts

Browse files
Files changed (1) hide show
  1. Dockerfile +108 -0
Dockerfile ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ # Use NVIDIA PyTorch container as base image
17
+ FROM nvcr.io/nvidia/pytorch:24.10-py3
18
+
19
+ # Install basic tools and clean apt cache
20
+ RUN apt-get update && apt-get install -y git tree ffmpeg wget \
21
+ && apt-get clean \
22
+ && rm -rf /var/lib/apt/lists/*
23
+
24
+ # Create symlinks for bash and libcuda
25
+ RUN rm /bin/sh && ln -s /bin/bash /bin/sh && ln -s /lib64/libcuda.so.1 /lib64/libcuda.so
26
+
27
+ # Set the working directory inside the container
28
+ WORKDIR /app
29
+
30
+ # Copy the cosmos-predict1.yaml and requirements.txt files to the container root
31
+ COPY ./cosmos-predict1.yaml /cosmos-predict1.yaml
32
+ COPY ./requirements.txt /requirements.txt
33
+
34
+ # Copy all your project files (including gui/, cosmos_predict1/, etc.) into the /app directory.
35
+ COPY . /app
36
+
37
+ # Step 1: Install Miniconda
38
+ # Install Miniconda to /opt/miniconda3 for consistency
39
+ RUN echo "Installing Miniconda..." && \
40
+ mkdir -p /opt/miniconda3 && \
41
+ wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /opt/miniconda3/miniconda.sh && \
42
+ bash /opt/miniconda3/miniconda.sh -b -u -p /opt/miniconda3 && \
43
+ rm /opt/miniconda3/miniconda.sh
44
+
45
+ # Step 2: Configure Conda and set PATH
46
+ # Add Miniconda to PATH for current and subsequent RUN commands
47
+ ENV PATH="/opt/miniconda3/bin:$PATH"
48
+ RUN echo "Configuring Conda..." && \
49
+ conda config --set auto_activate_base false && \
50
+ conda config --set auto_update_conda false && \
51
+ conda config --set show_channel_urls true && \
52
+ conda config --set channel_priority strict && \
53
+ conda config --set safety_checks disabled && \
54
+ conda config --add channels conda-forge && \
55
+ conda config --set always_yes true && \
56
+ conda config --set restore_free_channel true && \
57
+ conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main && \
58
+ conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r
59
+
60
+ # Step 3: Create the conda environment from the YAML file
61
+ RUN echo "Creating conda environment from YAML..." && \
62
+ conda env create --file /cosmos-predict1.yaml
63
+
64
+ # Step 4: Activate environment and install core pip requirements
65
+ # Add the new environment's bin directory to PATH for subsequent `pip` calls
66
+ ENV PATH="/opt/miniconda3/envs/cosmos-predict1/bin:$PATH"
67
+ RUN echo "Installing core pip requirements from requirements.txt..." && \
68
+ pip install --no-cache-dir -r /requirements.txt
69
+
70
+ # Step 5: Create necessary symlinks
71
+ # Use CONDA_PREFIX if set, otherwise fallback to expected path
72
+ RUN echo "Creating symlinks..." && \
73
+ ln -sf ${CONDA_PREFIX:-/opt/miniconda3/envs/cosmos-predict1}/lib/python3.10/site-packages/nvidia/*/include/* ${CONDA_PREFIX:-/opt/miniconda3/envs/cosmos-predict1}/include/ && \
74
+ ln -sf ${CONDA_PREFIX:-/opt/miniconda3/envs/cosmos-predict1}/lib/python3.10/site-packages/nvidia/*/include/* ${CONDA_PREFIX:-/opt/miniconda3/envs/cosmos-predict1}/include/python3.10 && \
75
+ ln -sf ${CONDA_PREFIX:-/opt/miniconda3/envs/cosmos-predict1}/lib/python3.10/site-packages/triton/backends/nvidia/include/* ${CONDA_PREFIX:-/opt/miniconda3/envs/cosmos-predict1}/include/
76
+
77
+ # Step 6: Install specific pip packages
78
+ RUN echo "Installing specific pip packages..." && \
79
+ pip install "fastapi[standard]" && \
80
+ pip install pyexr && \
81
+ pip install transformer-engine[pytorch]==1.12.0
82
+
83
+ # Step 7: Clone and install Apex
84
+ RUN echo "Cloning and installing Apex..." && \
85
+ git clone https://github.com/NVIDIA/apex /app/apex_temp && \
86
+ cd /app/apex_temp && \
87
+ CUDA_HOME=${CONDA_PREFIX:-/opt/miniconda3/envs/cosmos-predict1} pip install -v --disable-pip-version-check --no-cache-dir --no-build-isolation --config-settings "--build-option=--cpp_ext" --config-settings "--build-option=--cuda_ext" . && \
88
+ rm -rf /app/apex_temp # Clean up cloned repo after install
89
+
90
+ # Step 8: Install MoGe
91
+ RUN echo "Installing MoGe..." && \
92
+ pip install git+https://github.com/microsoft/MoGe.git
93
+
94
+ # Set environment variables for your application at runtime
95
+ # Assumes your checkpoints are in /app/checkpoints after COPY . /app
96
+ ENV GEN3C_CKPT_PATH="/app/checkpoints"
97
+ # Specify GPU count if your app needs it (e.g., "ALL" for all available)
98
+ ENV GEN3C_GPU_COUNT="ALL"
99
+ # Standard path for CUDA_HOME in NVIDIA PyTorch Docker images
100
+ ENV CUDA_HOME="/usr/local/cuda"
101
+
102
+ # Expose the port your FastAPI server will listen on
103
+ EXPOSE 7860
104
+
105
+ # Default command: Activate the conda environment and then run the FastAPI server.
106
+ # This ensures all your dependencies are available and the server starts correctly.
107
+ # 'gui.api.server:app' is the correct path for your FastAPI application.
108
+ CMD ["bash", "-c", "source /opt/miniconda3/bin/activate cosmos-predict1 && uvicorn gui.api.server:app --host 0.0.0.0 --port 7860"]