Web Admin

parent f4a34bc3
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
venv/ venv/
.venv/ .venv/
env/ env/
venv_all/
# Python cache # Python cache
__pycache__/ __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 #!/bin/bash
# Build script for CoderAI - Supports NVIDIA (CUDA), Vulkan, OpenCL, and CPU backends # 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) # Default: all (installs all backends)
# --flash: Enable and install Flash Attention 2 (for NVIDIA GPUs) # --flash: Enable and install Flash Attention 2 (for NVIDIA GPUs)
# --venv <venv>: Specify custom virtual environment name
set -e set -e
...@@ -16,12 +17,21 @@ NC='\033[0m' # No Color ...@@ -16,12 +17,21 @@ NC='\033[0m' # No Color
# Determine backend and flags # Determine backend and flags
BACKEND="${1:-all}" BACKEND="${1:-all}"
FLASH=false FLASH=false
CUSTOM_VENV=""
# Check for --flash flag in any position # Parse arguments
i=1
for arg in "$@"; do for arg in "$@"; do
case $arg in case $arg in
--flash) FLASH=true;; --flash)
FLASH=true
;;
--venv)
i=$((i + 1))
eval "CUSTOM_VENV=\${$i}"
;;
esac esac
i=$((i + 1))
done done
BACKEND=$(echo "$BACKEND" | tr '[:upper:]' '[:lower:]') BACKEND=$(echo "$BACKEND" | tr '[:upper:]' '[:lower:]')
...@@ -61,8 +71,23 @@ fi ...@@ -61,8 +71,23 @@ fi
echo -e "${GREEN}✓ Python version: $PYTHON_VERSION${NC}" 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 # 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" VENV_DIR="venv_nvidia"
elif [ "$BACKEND" = "vulkan" ]; then elif [ "$BACKEND" = "vulkan" ]; then
VENV_DIR="venv_vulkan" VENV_DIR="venv_vulkan"
...@@ -77,7 +102,11 @@ elif [ "$BACKEND" = "all" ]; then ...@@ -77,7 +102,11 @@ elif [ "$BACKEND" = "all" ]; then
fi fi
# Create virtual environment if it doesn't exist # 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 if [ ! -d "$VENV_DIR" ]; then
python3 -m venv "$VENV_DIR" python3 -m venv "$VENV_DIR"
echo -e "${GREEN}✓ Created virtual environment: $VENV_DIR${NC}" echo -e "${GREEN}✓ Created virtual environment: $VENV_DIR${NC}"
...@@ -116,7 +145,7 @@ if [ "$BACKEND" = "nvidia" ]; then ...@@ -116,7 +145,7 @@ if [ "$BACKEND" = "nvidia" ]; then
echo "" echo ""
echo -e "${YELLOW}Installing Flash Attention 2...${NC}" echo -e "${YELLOW}Installing Flash Attention 2...${NC}"
echo -e "${YELLOW}This may take several minutes and requires CUDA 11.6+${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 "${RED}Warning: Flash Attention 2 installation failed${NC}"
echo -e "${YELLOW}Requirements: CUDA 11.6+, Linux, Ampere/Ada/Hopper GPU${NC}" echo -e "${YELLOW}Requirements: CUDA 11.6+, Linux, Ampere/Ada/Hopper GPU${NC}"
echo -e "${YELLOW}Continuing without Flash Attention...${NC}" echo -e "${YELLOW}Continuing without Flash Attention...${NC}"
...@@ -394,9 +423,9 @@ elif [ "$BACKEND" = "opencl" ]; then ...@@ -394,9 +423,9 @@ elif [ "$BACKEND" = "opencl" ]; then
echo -e "${YELLOW}Installing base requirements...${NC}" echo -e "${YELLOW}Installing base requirements...${NC}"
pip install -r requirements.txt 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}" 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 ""
echo -e "${YELLOW}Note: If stable-diffusion-cpp-python is not available with pip,${NC}" 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}" echo -e "${YELLOW}you may need to build from source.${NC}"
...@@ -448,11 +477,10 @@ elif [ "$BACKEND" = "all" ]; then ...@@ -448,11 +477,10 @@ elif [ "$BACKEND" = "all" ]; then
pip install whispercpp || echo -e "${YELLOW}Warning: whispercpp failed${NC}" pip install whispercpp || echo -e "${YELLOW}Warning: whispercpp failed${NC}"
pip install litellm || echo -e "${YELLOW}Warning: litellm failed${NC}" pip install litellm || echo -e "${YELLOW}Warning: litellm failed${NC}"
# Try procname (may fail on Python 3.13) pip install setproctitle || echo -e "${YELLOW}Warning: setproctitle failed (optional)${NC}"
pip install procname || echo -e "${YELLOW}Warning: procname failed (optional)${NC}"
# Try stable-diffusion-cpp-python (disable WebM to avoid missing libwebm cmake submodule)
# Try stable-diffusion-cpp-python (requires CMake) CMAKE_ARGS="$SD_CMAKE_ARGS" pip install stable-diffusion-cpp-python || echo -e "${YELLOW}Warning: stable-diffusion-cpp-python failed (optional)${NC}"
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) # Install PyTorch with CUDA support (for nvidia backend)
...@@ -540,23 +568,23 @@ elif [ "$BACKEND" = "all" ]; then ...@@ -540,23 +568,23 @@ elif [ "$BACKEND" = "all" ]; then
# Try to install stable-diffusion-cpp-python with OpenCL # Try to install stable-diffusion-cpp-python with OpenCL
if [ "$OPENCL_AVAILABLE" = true ]; then if [ "$OPENCL_AVAILABLE" = true ]; then
echo -e "${YELLOW}Installing stable-diffusion-cpp-python with OpenCL support...${NC}" 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}" echo -e "${YELLOW}Warning: stable-diffusion-cpp-python not available (requires CMake and build tools)${NC}"
} }
else else
echo -e "${YELLOW}Skipping OpenCL (stable-diffusion-cpp-python) - OpenCL not available${NC}" echo -e "${YELLOW}Skipping OpenCL (stable-diffusion-cpp-python) - OpenCL not available${NC}"
fi fi
# Install additional requirements # Install additional requirements
echo -e "${YELLOW}Installing additional requirements...${NC}" echo -e "${YELLOW}Installing additional requirements...${NC}"
pip install numpy pillow || { pip install numpy pillow || {
echo -e "${YELLOW}Warning: Some additional packages failed${NC}" echo -e "${YELLOW}Warning: Some additional packages failed${NC}"
} }
# Try procname (optional, may fail on Python 3.13) # Install setproctitle for process naming (Python 3.13 compatible)
echo -e "${YELLOW}Installing procname (optional)...${NC}" echo -e "${YELLOW}Installing setproctitle...${NC}"
pip install procname || { pip install setproctitle || {
echo -e "${YELLOW}Note: procname failed to install (optional package, not critical)${NC}" echo -e "${YELLOW}Note: setproctitle failed to install (optional package, not critical)${NC}"
} }
# Install Flash Attention 2 if requested and CUDA is available # Install Flash Attention 2 if requested and CUDA is available
...@@ -564,7 +592,7 @@ elif [ "$BACKEND" = "all" ]; then ...@@ -564,7 +592,7 @@ elif [ "$BACKEND" = "all" ]; then
echo "" echo ""
echo -e "${YELLOW}Installing Flash Attention 2...${NC}" echo -e "${YELLOW}Installing Flash Attention 2...${NC}"
echo -e "${YELLOW}This may take several minutes and requires CUDA 11.6+${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 "${RED}Warning: Flash Attention 2 installation failed${NC}"
echo -e "${YELLOW}Requirements: CUDA 11.6+, Linux, Ampere/Ada/Hopper GPU${NC}" echo -e "${YELLOW}Requirements: CUDA 11.6+, Linux, Ampere/Ada/Hopper GPU${NC}"
echo -e "${YELLOW}Continuing without Flash Attention...${NC}" echo -e "${YELLOW}Continuing without Flash Attention...${NC}"
......
This diff is collapsed.
...@@ -18,10 +18,10 @@ def main(): ...@@ -18,10 +18,10 @@ def main():
original_unraisablehook(unraisable) original_unraisablehook(unraisable)
sys.unraisablehook = suppress_llama_del_errors sys.unraisablehook = suppress_llama_del_errors
# Optional: set process name if procname is available # Optional: set process name if setproctitle is available
try: try:
import procname import setproctitle
procname.setprocname("codai") setproctitle.setproctitle("codai")
except ImportError: except ImportError:
pass pass
......
This diff is collapsed.
...@@ -15,7 +15,7 @@ psutil>=5.9.0 ...@@ -15,7 +15,7 @@ psutil>=5.9.0
# Optional: Audio transcription dependencies # Optional: Audio transcription dependencies
faster-whisper>=0.10.0 # For NVIDIA/CUDA whisper transcription 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 # Optional: for better performance with NVIDIA GPUs
bitsandbytes>=0.41.0 bitsandbytes>=0.41.0
......
...@@ -17,4 +17,4 @@ huggingface-hub>=0.19.0 ...@@ -17,4 +17,4 @@ huggingface-hub>=0.19.0
# Optional: Audio transcription without PyTorch (whispercpp) # Optional: Audio transcription without PyTorch (whispercpp)
# Note: faster-whisper requires PyTorch, but whispercpp works without it # 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 ...@@ -36,15 +36,15 @@ transformers>=4.35.0
accelerate>=0.24.0 accelerate>=0.24.0
diffusers>=0.25.0 # For Stable Diffusion image generation diffusers>=0.25.0 # For Stable Diffusion image generation
safetensors>=0.4.0 # Required by diffusers 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 # System resource detection
psutil>=5.9.0 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 # Optional: Audio transcription dependencies
faster-whisper>=0.10.0 # For NVIDIA/CUDA whisper transcription 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 for standardized API responses
litellm>=1.40.0 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