Spaces:
Build error
Build error
Fix PyTorch verification command in Dockerfile to avoid f-string syntax error
Browse files- Dockerfile +10 -8
Dockerfile
CHANGED
|
@@ -32,14 +32,11 @@ RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86
|
|
| 32 |
conda config --set auto_activate_base false && \
|
| 33 |
conda config --add channels conda-forge
|
| 34 |
|
| 35 |
-
#
|
| 36 |
-
# This is required for non-interactive environments like Docker builds.
|
| 37 |
-
# We source conda.sh first to make the 'conda' command available in this RUN layer.
|
| 38 |
# We use '. ' (dot space) instead of 'source' as /bin/sh is the default shell.
|
| 39 |
RUN . $CONDA_DIR/etc/profile.d/conda.sh && \
|
| 40 |
conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main && \
|
| 41 |
conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r
|
| 42 |
-
# --- END NEW ---
|
| 43 |
|
| 44 |
# Copy all local project files into the container's working directory (/app).
|
| 45 |
# This includes your cosmos-predict1.yaml, gui/requirements.txt, start.sh, etc.
|
|
@@ -55,14 +52,19 @@ ENV CONDA_DEFAULT_ENV=cosmos-predict1
|
|
| 55 |
# This ensures that executables (like python, pip, uvicorn) from this environment are found.
|
| 56 |
ENV PATH=$CONDA_DIR/envs/cosmos-predict1/bin:$PATH
|
| 57 |
|
| 58 |
-
# --- Verification Steps
|
| 59 |
-
# These commands help confirm that Python, Conda, and PyTorch are set up correctly.
|
| 60 |
RUN echo "Verifying Python and Conda installations..."
|
| 61 |
RUN python --version
|
| 62 |
RUN conda env list
|
| 63 |
RUN echo "Verifying PyTorch and CUDA availability..."
|
| 64 |
-
# Use
|
| 65 |
-
RUN conda run -n cosmos-predict1 python -c "import torch;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
# --- End Verification Steps ---
|
| 67 |
|
| 68 |
# Make the start.sh script executable.
|
|
|
|
| 32 |
conda config --set auto_activate_base false && \
|
| 33 |
conda config --add channels conda-forge
|
| 34 |
|
| 35 |
+
# Accept Conda Terms of Service for default channels.
|
|
|
|
|
|
|
| 36 |
# We use '. ' (dot space) instead of 'source' as /bin/sh is the default shell.
|
| 37 |
RUN . $CONDA_DIR/etc/profile.d/conda.sh && \
|
| 38 |
conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main && \
|
| 39 |
conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r
|
|
|
|
| 40 |
|
| 41 |
# Copy all local project files into the container's working directory (/app).
|
| 42 |
# This includes your cosmos-predict1.yaml, gui/requirements.txt, start.sh, etc.
|
|
|
|
| 52 |
# This ensures that executables (like python, pip, uvicorn) from this environment are found.
|
| 53 |
ENV PATH=$CONDA_DIR/envs/cosmos-predict1/bin:$PATH
|
| 54 |
|
| 55 |
+
# --- Verification Steps ---
|
|
|
|
| 56 |
RUN echo "Verifying Python and Conda installations..."
|
| 57 |
RUN python --version
|
| 58 |
RUN conda env list
|
| 59 |
RUN echo "Verifying PyTorch and CUDA availability..."
|
| 60 |
+
# REVISED: Use simpler string concatenation and conditional logic in Python
|
| 61 |
+
RUN conda run -n cosmos-predict1 python -c "import torch; \
|
| 62 |
+
print('PyTorch Version: ' + torch.__version__); \
|
| 63 |
+
print('CUDA Available: ' + str(torch.cuda.is_available())); \
|
| 64 |
+
if torch.cuda.is_available(): \
|
| 65 |
+
print('CUDA Device Name: ' + torch.cuda.get_device_name(0)); \
|
| 66 |
+
else: \
|
| 67 |
+
print('CUDA Device Name: N/A')" || echo "PyTorch verification failed. Check dependencies in cosmos-predict1.yaml."
|
| 68 |
# --- End Verification Steps ---
|
| 69 |
|
| 70 |
# Make the start.sh script executable.
|