Spaces:
Sleeping
Sleeping
File size: 1,912 Bytes
c42fe7e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# Activate the virtual environment
source venv/bin/activate
# Load necessary modules only if not already loaded
if ! module list 2>&1 | grep -q gcc; then
module load gcc/12.3
fi
if ! module list 2>&1 | grep -q arrow; then
module load gcc arrow/19.0.1 python/3.11
fi
if ! module list 2>&1 | grep -q cuda; then
module load cuda
fi
# Create virtual environment if it doesn't exist
if [ ! -d "venv" ]; then
echo "Creating virtual environment..."
python3.11 -m venv venv
else
echo "Virtual environment already exists, skipping creation."
fi
# Verify if virtual environment is active
if [ -z "$VIRTUAL_ENV" ]; then
echo "β Error: Virtual environment is not active after activation attempt."
echo "Exiting to avoid broken installations."
exit 1
fi
# Upgrade pip
pip install --upgrade pip
# Install PyTorch manually first (important for compatibility)
pip install --no-index torch torchvision torchaudio
pip install streamlit tornado pytest lxml pyyaml lightning
module load scipy-stack
# Check if torch and torchvision are installed correctly
TORCH_VERSION=$(python -c "import torch; print(torch.__version__)" 2>/dev/null || echo "")
VISION_VERSION=$(python -c "import torchvision; print(torchvision.__version__)" 2>/dev/null || echo "")
if [ -z "$TORCH_VERSION" ] || [ -z "$VISION_VERSION" ]; then
echo "β Error: torch or torchvision not installed correctly."
exit 1
fi
echo "β
torch version: $TORCH_VERSION"
echo "β
torchvision version: $VISION_VERSION"
# Install remaining project dependencies unless in dev mode
if [ "$dev" != "1" ]; then
source venv/bin/activate
echo "Installing project requirements..."
pip install -r requirements.txt
pip install tornado scipy pillow pandas six packaging==24.0 decorator
else
echo "β‘ Dev mode active: Skipping pip install -r requirements.txt"
fi
# Final success message
echo "π Environment setup complete! Ready to go."
|