Spaces:
Build error
Build error
Robustly locate and activate conda environment in start.sh
Browse files
README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
---
|
| 2 |
-
title: GEN3C Project (from
|
| 3 |
emoji: 🫁
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: blue
|
|
|
|
| 1 |
---
|
| 2 |
+
title: GEN3C Project (built from existing Docker image)
|
| 3 |
emoji: 🫁
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: blue
|
start.sh
CHANGED
|
@@ -1,22 +1,47 @@
|
|
| 1 |
#!/bin/bash
|
| 2 |
-
set -eux # Keep this for
|
| 3 |
|
| 4 |
export CUDA_VISIBLE_DEVICES="0"
|
| 5 |
export CUDA_HOME="/usr/local/cuda"
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
#
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
# Activate the specific conda environment
|
| 16 |
-
conda activate cosmos-predict1 || { echo "ERROR: Failed to activate conda environment 'cosmos-predict1'. Ensure it exists."; exit 1; }
|
| 17 |
|
| 18 |
-
# Set PYTHONPATH
|
| 19 |
-
# This ensures local project paths are prioritized/available for your application's modules.
|
| 20 |
export PYTHONPATH="/app:/app/gui/api"
|
| 21 |
|
| 22 |
echo "Starting GEN3C FastAPI inference server..."
|
|
@@ -25,5 +50,4 @@ export GEN3C_CKPT_PATH="/app/checkpoints"
|
|
| 25 |
export GEN3C_GPU_COUNT=1
|
| 26 |
|
| 27 |
# Start the FastAPI server
|
| 28 |
-
# It's crucial that 'uvicorn' is installed and available within the 'cosmos-predict1' environment.
|
| 29 |
exec uvicorn gui.api.server:app --host 0.0.0.0 --port 7860 --proxy-headers
|
|
|
|
| 1 |
#!/bin/bash
|
| 2 |
+
set -eux # Keep this for detailed logging
|
| 3 |
|
| 4 |
export CUDA_VISIBLE_DEVICES="0"
|
| 5 |
export CUDA_HOME="/usr/local/cuda"
|
| 6 |
|
| 7 |
+
echo "Attempting to locate and activate Conda environment..."
|
| 8 |
+
|
| 9 |
+
# 1. Try to find the 'conda' executable in the system's PATH
|
| 10 |
+
CONDA_EXEC=$(which conda)
|
| 11 |
+
|
| 12 |
+
if [ -z "$CONDA_EXEC" ]; then
|
| 13 |
+
echo "ERROR: 'conda' executable not found in PATH."
|
| 14 |
+
echo "This means Conda might not be installed in the base image, or it's not configured in the system's PATH."
|
| 15 |
+
echo "Please check if 'elungky/gen3c:latest' image actually contains a working Conda installation."
|
| 16 |
+
exit 1
|
| 17 |
+
fi
|
| 18 |
+
|
| 19 |
+
echo "Found 'conda' executable at: $CONDA_EXEC"
|
| 20 |
+
|
| 21 |
+
# 2. Derive the base Conda installation path from the executable's location.
|
| 22 |
+
# For example, if CONDA_EXEC is /opt/conda/bin/conda, CONDA_BASE_PATH will be /opt/conda.
|
| 23 |
+
CONDA_BASE_PATH=$(dirname $(dirname "$CONDA_EXEC"))
|
| 24 |
+
echo "Derived Conda base path: $CONDA_BASE_PATH"
|
| 25 |
+
|
| 26 |
+
# 3. Construct the path to conda.sh script based on the derived base path
|
| 27 |
+
CONDA_SH_PATH="$CONDA_BASE_PATH/etc/profile.d/conda.sh"
|
| 28 |
+
|
| 29 |
+
if [ -f "$CONDA_SH_PATH" ]; then
|
| 30 |
+
echo "Found conda.sh at: $CONDA_SH_PATH"
|
| 31 |
+
# Attempt to source it. Capture potential errors from sourcing itself.
|
| 32 |
+
source "$CONDA_SH_PATH" || { echo "ERROR: Failed to source conda.sh script at $CONDA_SH_PATH. Check permissions."; exit 1; }
|
| 33 |
+
else
|
| 34 |
+
echo "ERROR: conda.sh not found at expected location derived from 'conda' executable: $CONDA_SH_PATH"
|
| 35 |
+
echo "This indicates an unusual Conda installation or structure within the base image."
|
| 36 |
+
exit 1
|
| 37 |
+
fi
|
| 38 |
+
|
| 39 |
+
echo "Conda environment initialized successfully."
|
| 40 |
|
| 41 |
# Activate the specific conda environment
|
| 42 |
+
conda activate cosmos-predict1 || { echo "ERROR: Failed to activate conda environment 'cosmos-predict1'. Ensure it exists and is accessible for this user."; exit 1; }
|
| 43 |
|
| 44 |
+
# Set PYTHONPATH after conda activation, as conda might adjust PATH/PYTHONPATH internally.
|
|
|
|
| 45 |
export PYTHONPATH="/app:/app/gui/api"
|
| 46 |
|
| 47 |
echo "Starting GEN3C FastAPI inference server..."
|
|
|
|
| 50 |
export GEN3C_GPU_COUNT=1
|
| 51 |
|
| 52 |
# Start the FastAPI server
|
|
|
|
| 53 |
exec uvicorn gui.api.server:app --host 0.0.0.0 --port 7860 --proxy-headers
|