Web Admin

parent f4a34bc3
......@@ -5,6 +5,8 @@
venv/
.venv/
env/
venv_all/
# Python cache
__pycache__/
......
# Backend selection file
.backend
# Virtual environments
venv/
.venv/
env/
# Python cache
__pycache__/
*.pyc
*.pyo
*.pyd
.Python
# Debug logs
debug.log
# Test files
test_*.py
#!/bin/bash
# Build script for CoderAI - Supports NVIDIA (CUDA), Vulkan, OpenCL, and CPU backends
# Usage: ./build.sh [nvidia|vulkan|vulkan-nvidia|cuda|opencl|all] [--flash]
# Usage: ./build.sh [nvidia|vulkan|vulkan-nvidia|cuda|opencl|all] [--flash] [--venv <venv>]
# Default: all (installs all backends)
# --flash: Enable and install Flash Attention 2 (for NVIDIA GPUs)
# --venv <venv>: Specify custom virtual environment name
set -e
......@@ -16,12 +17,21 @@ NC='\033[0m' # No Color
# Determine backend and flags
BACKEND="${1:-all}"
FLASH=false
CUSTOM_VENV=""
# Check for --flash flag in any position
# Parse arguments
i=1
for arg in "$@"; do
case $arg in
--flash) FLASH=true;;
--flash)
FLASH=true
;;
--venv)
i=$((i + 1))
eval "CUSTOM_VENV=\${$i}"
;;
esac
i=$((i + 1))
done
BACKEND=$(echo "$BACKEND" | tr '[:upper:]' '[:lower:]')
......@@ -61,8 +71,23 @@ fi
echo -e "${GREEN}✓ Python version: $PYTHON_VERSION${NC}"
# Determine cmake args for stable-diffusion-cpp-python.
# The pip release is missing the libwebm/build/ cmake submodule files.
# If libwebm-dev is installed system-wide we can link against it; otherwise disable WebM.
if ldconfig -p 2>/dev/null | grep -q "libwebm" || pkg-config --exists libwebm 2>/dev/null; then
SD_CMAKE_ARGS="-DSD_USE_SYSTEM_WEBM=ON"
echo -e "${GREEN}✓ Found system libwebm — stable-diffusion-cpp-python will use it${NC}"
else
SD_CMAKE_ARGS="-DSD_WEBM=OFF"
echo -e "${YELLOW}Note: libwebm-dev not found — WebM video output disabled for stable-diffusion-cpp-python${NC}"
echo -e "${YELLOW} Install libwebm-dev to enable WebM support${NC}"
fi
# Determine venv directory based on backend
if [ "$BACKEND" = "nvidia" ]; then
if [ -n "$CUSTOM_VENV" ]; then
VENV_DIR="$CUSTOM_VENV"
echo -e "${BLUE}Using custom virtual environment: $VENV_DIR${NC}"
elif [ "$BACKEND" = "nvidia" ]; then
VENV_DIR="venv_nvidia"
elif [ "$BACKEND" = "vulkan" ]; then
VENV_DIR="venv_vulkan"
......@@ -77,7 +102,11 @@ elif [ "$BACKEND" = "all" ]; then
fi
# Create virtual environment if it doesn't exist
echo -e "${YELLOW}Creating virtual environment: $VENV_DIR${NC}"
if [ -n "$CUSTOM_VENV" ]; then
echo -e "${YELLOW}Creating custom virtual environment: $VENV_DIR${NC}"
else
echo -e "${YELLOW}Creating virtual environment: $VENV_DIR${NC}"
fi
if [ ! -d "$VENV_DIR" ]; then
python3 -m venv "$VENV_DIR"
echo -e "${GREEN}✓ Created virtual environment: $VENV_DIR${NC}"
......@@ -116,7 +145,7 @@ if [ "$BACKEND" = "nvidia" ]; then
echo ""
echo -e "${YELLOW}Installing Flash Attention 2...${NC}"
echo -e "${YELLOW}This may take several minutes and requires CUDA 11.6+${NC}"
pip install flash-attn --no-build-isolation || {
MAX_JOBS=5 NVCC_THREADS=2 pip install flash-attn --no-build-isolation || {
echo -e "${RED}Warning: Flash Attention 2 installation failed${NC}"
echo -e "${YELLOW}Requirements: CUDA 11.6+, Linux, Ampere/Ada/Hopper GPU${NC}"
echo -e "${YELLOW}Continuing without Flash Attention...${NC}"
......@@ -394,9 +423,9 @@ elif [ "$BACKEND" = "opencl" ]; then
echo -e "${YELLOW}Installing base requirements...${NC}"
pip install -r requirements.txt
# Install stable-diffusion-cpp-python with OpenCL
# Install stable-diffusion-cpp-python with OpenCL (disable WebM to avoid libwebm cmake issue)
echo -e "${YELLOW}Installing stable-diffusion-cpp-python with OpenCL...${NC}"
pip install stable-diffusion-cpp-python || {
CMAKE_ARGS="$SD_CMAKE_ARGS" pip install stable-diffusion-cpp-python || {
echo ""
echo -e "${YELLOW}Note: If stable-diffusion-cpp-python is not available with pip,${NC}"
echo -e "${YELLOW}you may need to build from source.${NC}"
......@@ -448,11 +477,10 @@ elif [ "$BACKEND" = "all" ]; then
pip install whispercpp || echo -e "${YELLOW}Warning: whispercpp failed${NC}"
pip install litellm || echo -e "${YELLOW}Warning: litellm failed${NC}"
# Try procname (may fail on Python 3.13)
pip install procname || echo -e "${YELLOW}Warning: procname failed (optional)${NC}"
# Try stable-diffusion-cpp-python (requires CMake)
pip install stable-diffusion-cpp-python || echo -e "${YELLOW}Warning: stable-diffusion-cpp-python failed (optional)${NC}"
pip install setproctitle || echo -e "${YELLOW}Warning: setproctitle failed (optional)${NC}"
# Try stable-diffusion-cpp-python (disable WebM to avoid missing libwebm cmake submodule)
CMAKE_ARGS="$SD_CMAKE_ARGS" pip install stable-diffusion-cpp-python || echo -e "${YELLOW}Warning: stable-diffusion-cpp-python failed (optional)${NC}"
}
# Install PyTorch with CUDA support (for nvidia backend)
......@@ -540,23 +568,23 @@ elif [ "$BACKEND" = "all" ]; then
# Try to install stable-diffusion-cpp-python with OpenCL
if [ "$OPENCL_AVAILABLE" = true ]; then
echo -e "${YELLOW}Installing stable-diffusion-cpp-python with OpenCL support...${NC}"
pip install stable-diffusion-cpp-python || {
CMAKE_ARGS="$SD_CMAKE_ARGS" pip install stable-diffusion-cpp-python || {
echo -e "${YELLOW}Warning: stable-diffusion-cpp-python not available (requires CMake and build tools)${NC}"
}
else
echo -e "${YELLOW}Skipping OpenCL (stable-diffusion-cpp-python) - OpenCL not available${NC}"
fi
# Install additional requirements
echo -e "${YELLOW}Installing additional requirements...${NC}"
pip install numpy pillow || {
echo -e "${YELLOW}Warning: Some additional packages failed${NC}"
}
# Try procname (optional, may fail on Python 3.13)
echo -e "${YELLOW}Installing procname (optional)...${NC}"
pip install procname || {
echo -e "${YELLOW}Note: procname failed to install (optional package, not critical)${NC}"
# Install setproctitle for process naming (Python 3.13 compatible)
echo -e "${YELLOW}Installing setproctitle...${NC}"
pip install setproctitle || {
echo -e "${YELLOW}Note: setproctitle failed to install (optional package, not critical)${NC}"
}
# Install Flash Attention 2 if requested and CUDA is available
......@@ -564,7 +592,7 @@ elif [ "$BACKEND" = "all" ]; then
echo ""
echo -e "${YELLOW}Installing Flash Attention 2...${NC}"
echo -e "${YELLOW}This may take several minutes and requires CUDA 11.6+${NC}"
pip install flash-attn --no-build-isolation || {
MAX_JOBS=5 NVCC_THREADS=2 pip install flash-attn --no-build-isolation || {
echo -e "${RED}Warning: Flash Attention 2 installation failed${NC}"
echo -e "${YELLOW}Requirements: CUDA 11.6+, Linux, Ampere/Ada/Hopper GPU${NC}"
echo -e "${YELLOW}Continuing without Flash Attention...${NC}"
......
This diff is collapsed.
......@@ -18,10 +18,10 @@ def main():
original_unraisablehook(unraisable)
sys.unraisablehook = suppress_llama_del_errors
# Optional: set process name if procname is available
# Optional: set process name if setproctitle is available
try:
import procname
procname.setprocname("codai")
import setproctitle
setproctitle.setproctitle("codai")
except ImportError:
pass
......
This diff is collapsed.
......@@ -15,7 +15,7 @@ psutil>=5.9.0
# Optional: Audio transcription dependencies
faster-whisper>=0.10.0 # For NVIDIA/CUDA whisper transcription
whispercpp>=1.0.0 # Alternative whisper library (works without PyTorch)
whispercpp>=0.0.17 # Alternative whisper library (works without PyTorch)
# Optional: for better performance with NVIDIA GPUs
bitsandbytes>=0.41.0
......
......@@ -17,4 +17,4 @@ huggingface-hub>=0.19.0
# Optional: Audio transcription without PyTorch (whispercpp)
# Note: faster-whisper requires PyTorch, but whispercpp works without it
whispercpp>=1.0.0 # For GGUF-based Whisper transcription without PyTorch
whispercpp>=0.0.17 # For GGUF-based Whisper transcription without PyTorch
......@@ -36,15 +36,15 @@ transformers>=4.35.0
accelerate>=0.24.0
diffusers>=0.25.0 # For Stable Diffusion image generation
safetensors>=0.4.0 # Required by diffusers
stable-diffusion-cpp-python # For Vulkan/AMD image generation (no version pin for Python 3.13 compat)
# stable-diffusion-cpp-python is installed by build.sh with CMAKE_ARGS to fix the libwebm submodule issue
# System resource detection
psutil>=5.9.0
procname # Process naming (no version pin for Python 3.13 compatibility)
setproctitle>=1.1 # Process naming (replaces procname, Python 3.13 compatible)
# Optional: Audio transcription dependencies
faster-whisper>=0.10.0 # For NVIDIA/CUDA whisper transcription
whispercpp>=0.0.6 # Alternative whisper library (works without PyTorch)
whispercpp>=0.0.17 # Alternative whisper library (works without PyTorch)
# LiteLLM for standardized API responses
litellm>=1.40.0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment