gen3c / start.sh
elungky's picture
Attempt to fix conda path by adding /opt/conda/bin to PATH
4ad0a28
raw
history blame
1.97 kB
#!/bin/bash
set -eux # Keep this for detailed logging
export CUDA_VISIBLE_DEVICES="0"
export CUDA_HOME="/usr/local/cuda"
echo "Attempting to locate and activate Conda environment..."
# Add a common Conda binary path to PATH *before* trying to find 'conda'
# This is crucial if conda is installed but not in the default PATH
export PATH="/opt/conda/bin:$PATH"
# 1. Try to find the 'conda' executable in the system's PATH
CONDA_EXEC=$(which conda)
if [ -z "$CONDA_EXEC" ]; then
echo "ERROR: 'conda' executable still not found in PATH even after adding /opt/conda/bin."
echo "This indicates that Conda might be installed in a different location, or not at all."
exit 1
fi
echo "Found 'conda' executable at: $CONDA_EXEC"
# 2. Derive the base Conda installation path from the executable's location.
CONDA_BASE_PATH=$(dirname $(dirname "$CONDA_EXEC"))
echo "Derived Conda base path: $CONDA_BASE_PATH"
# 3. Construct the path to conda.sh script based on the derived base path
CONDA_SH_PATH="$CONDA_BASE_PATH/etc/profile.d/conda.sh"
if [ -f "$CONDA_SH_PATH" ]; then
echo "Found conda.sh at: $CONDA_SH_PATH"
source "$CONDA_SH_PATH" || { echo "ERROR: Failed to source conda.sh script at $CONDA_SH_PATH. Check permissions."; exit 1; }
else
echo "ERROR: conda.sh not found at expected location derived from 'conda' executable: $CONDA_SH_PATH"
exit 1
fi
echo "Conda environment initialized successfully."
# Activate the specific conda environment
conda activate cosmos-predict1 || { echo "ERROR: Failed to activate conda environment 'cosmos-predict1'. Ensure it exists and is accessible for this user."; exit 1; }
# Set PYTHONPATH after conda activation, as conda might adjust PATH/PYTHONPATH internally.
export PYTHONPATH="/app:/app/gui/api"
echo "Starting GEN3C FastAPI inference server..."
export GEN3C_CKPT_PATH="/app/checkpoints"
export GEN3C_GPU_COUNT=1
exec uvicorn gui.api.server:app --host 0.0.0.0 --port 7860 --proxy-headers