AI小龙虾OpenClaw安装指南

openclaw openclaw中文博客 1

系统要求

硬件要求

  • CPU: 4核以上(推荐8核+)
  • 内存: 16GB以上(推荐32GB)
  • GPU: NVIDIA RTX 3060以上(支持CUDA 11.0+)
  • 存储: 至少100GB可用空间(SSD推荐)

软件要求

  • 操作系统: Ubuntu 20.04/22.04 LTS, CentOS 8+, Windows 10/11
  • Python: 3.8-3.10
  • CUDA: 11.0-12.1(GPU版本需要)

快速安装(推荐)

方式1:使用Docker(最简单)

# 拉取OpenClaw镜像
docker pull openclaw/ai-crayfish:latest
# 运行容器
docker run -it --gpus all \
  -v $(pwd)/data:/app/data \
  -p 7860:7860 \
  openclaw/ai-crayfish:latest
# 访问Web界面
# 浏览器打开: http://localhost:7860

方式2:Conda环境安装

# 1. 克隆仓库
git clone https://github.com/OpenClaw/ai-crayfish.git
cd ai-crayfish
# 2. 创建conda环境
conda create -n openclaw python=3.9
conda activate openclaw
# 3. 安装依赖
pip install -r requirements.txt
# 4. 安装PyTorch(根据CUDA版本选择)
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
# 5. 安装OpenClaw核心包
pip install -e .

详细安装步骤

步骤1:环境准备

# Ubuntu/Debian
sudo apt update
sudo apt install -y git wget curl build-essential
sudo apt install -y libgl1-mesa-glx libglib2.0-0
# CentOS/RHEL
sudo yum install -y git wget curl gcc-c++
sudo yum install -y mesa-libGL glib2
# Windows
# 安装Visual Studio Build Tools
# 安装CUDA Toolkit(如需GPU支持)

步骤2:Python环境配置

# 使用pyenv管理多版本Python(可选)
curl https://pyenv.run | bash
pyenv install 3.9.18
pyenv global 3.9.18
# 验证Python版本
python --version

步骤3:安装OpenClaw

# 安装基础版本
pip install openclaw
# 安装完整版本(包含所有依赖)
pip install "openclaw[full]"
# 安装开发版本
git clone https://github.com/OpenClaw/ai-crayfish.git
cd ai-crayfish
pip install -e ".[dev,test]"

步骤4:模型下载

# 自动下载预训练模型
python -c "from openclaw import models; models.download_pretrained()"
# 或手动下载
mkdir -p ~/.openclaw/models
wget https://models.openclaw.ai/crayfish-detector-v2.pt -P ~/.openclaw/models/

配置说明

配置文件位置

# ~/.openclaw/config.yaml 或 ./config/config.yaml
model:
  device: "cuda:0"  # 或 "cpu"
  confidence_threshold: 0.6
  model_path: "models/crayfish-detector-v2.pt"
data:
  input_dir: "./input"
  output_dir: "./output"
  cache_dir: "./cache"
processing:
  batch_size: 8
  num_workers: 4
  image_size: 640

环境变量

export OPCLAW_MODEL_PATH="/path/to/models"
export OPCLAW_CACHE_DIR="/path/to/cache"
export OPCLAW_LOG_LEVEL="INFO"

验证安装

测试脚本

# test_installation.py
import openclaw
from openclaw.utils import check_install
print(f"OpenClaw版本: {openclaw.__version__}")
# 检查安装
result = check_install()
print(f"安装状态: {result}")
# 测试基本功能
from openclaw.detector import CrayfishDetector
detector = CrayfishDetector()
print("检测器加载成功!")

运行测试:

AI小龙虾OpenClaw安装指南-第1张图片-OpenClaw 中文版 - 真正能做事的 AI

python test_installation.py

常见问题解决

Q1: CUDA相关错误

# 检查CUDA安装
nvidia-smi
nvcc --version
# 如果CUDA未正确安装
# 重新安装PyTorch指定CUDA版本
pip uninstall torch torchvision torchaudio
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

Q2: 内存不足

# 修改config.yaml
processing:
  batch_size: 2  # 减小批大小
  use_amp: true  # 启用混合精度

Q3: 模型下载失败

# 设置代理
export http_proxy="http://your-proxy:port"
export https_proxy="http://your-proxy:port"
# 或手动下载
wget https://mirror.openclaw.ai/models/crayfish-detector-v2.pt

高级配置

多GPU训练

import torch
from openclaw.trainer import DistributedTrainer
# 自动检测可用GPU
if torch.cuda.device_count() > 1:
    trainer = DistributedTrainer(gpus=torch.cuda.device_count())
else:
    trainer = Trainer()

自定义模型

from openclaw.models import CustomModel
# 继承基础模型
class MyCrayfishModel(CustomModel):
    def __init__(self):
        super().__init__()
        # 添加自定义层

卸载

完全卸载

# 卸载Python包
pip uninstall openclaw -y
# 删除配置文件和模型
rm -rf ~/.openclaw
# 删除conda环境
conda deactivate
conda env remove -n openclaw

获取帮助

  • 📖 文档: https://docs.openclaw.ai
  • 💬 社区: https://forum.openclaw.ai
  • 🐛 问题: https://github.com/OpenClaw/ai-crayfish/issues
  • 📧 支持: support@openclaw.ai

更新日志

更新到最新版本

# 升级OpenClaw
pip install --upgrade openclaw
# 升级所有依赖
pip install --upgrade -r requirements.txt

注意:

  1. 首次运行可能需要较长时间下载模型文件
  2. 建议在虚拟环境中安装以避免依赖冲突
  3. GPU版本需要正确配置CUDA和cuDNN

安装完成后,运行以下命令启动Web界面:

openclaw-gui
# 或
python -m openclaw.web.app

抱歉,评论功能暂时关闭!