在Runpod上部署MAGI-1项目的完整指南
2025-06-30 16:33:20作者:韦蓉瑛
本文将详细介绍如何在Runpod云平台上部署MAGI-1项目,并解决常见的安装问题和配置错误。MAGI-1是一个基于PyTorch的多模态AI项目,需要特定的环境配置才能正常运行。
环境准备
首先需要设置基本环境变量和时区配置:
export HF_HOME=/workspace/
export TZ=America/Los_Angeles
创建Python虚拟环境并安装PyTorch基础包:
python -m venv venv
source /workspace/venv/bin/activate
pip install torch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0
依赖安装
安装必要的系统工具和Python包:
apt-get update
apt-get install -y ffmpeg
pip install ffmpeg ffmpeg-python
克隆项目仓库并安装依赖:
git clone https://github.com/SandAI-org/MAGI-1
cd MAGI-1
pip install --upgrade wheel setuptools setuptools_scm packaging
特别注意flash-attn需要单独安装以避免挂起问题:
pip install flash-attn --no-build-isolation
sed -i '/flash-attn/d' requirements.txt
pip install -r requirements.txt --no-build-isolation
安装MagiAttention模块
MagiAttention是项目核心组件,安装时需要足够的内存资源:
git clone https://github.com/SandAI-org/MagiAttention
cd MagiAttention
git submodule update --init --recursive
pip install --no-build-isolation .
cd ../
模型下载与配置
使用huggingface-cli高效下载所需模型:
pip install --upgrade huggingface_hub[hf_transfer]
export HF_HUB_ENABLE_HF_TRANSFER=1
对于4.5B模型:
huggingface-cli download sand-ai/MAGI-1 \
--local-dir ./downloads/t5_pretrained/t5-v1_1-xxl \
--include "ckpt/t5/t5-v1_1-xxl/*" \
--local-dir-use-symlinks False
huggingface-cli download sand-ai/MAGI-1 \
--local-dir ./downloads/vae \
--include "ckpt/vae/*" \
--local-dir-use-symlinks False
huggingface-cli download sand-ai/MAGI-1 \
--local-dir ./downloads/4.5B_base \
--include "ckpt/magi/4.5B_base/*" \
--local-dir-use-symlinks False
整理下载的模型文件:
mv ./downloads/t5_pretrained/t5-v1_1-xxl/ckpt/t5/t5-v1_1-xxl/* ./downloads/t5_pretrained/t5-v1_1-xxl/
mv ./downloads/vae/ckpt/vae/* ./downloads/vae/
mv ./downloads/4.5B_base/ckpt/magi/4.5B_base/* ./downloads/4.5B_base/
常见问题解决
-
CUDA设备设置:4.5B模型的run.sh脚本中需要将CUDA_VISIBLE_DEVICES设置为0而非1
-
24B模型配置:
- distill和fp8字段应设为false
- cfg_number必须设置为3
-
ffmpeg安装:必须同时通过apt-get和pip安装才能正常工作
-
内存问题:安装MagiAttention时至少需要H100级别的内存资源
持久化存储配置
当使用持久化存储时,每次启动需要重新设置环境:
export HF_HOME=/workspace/
export TZ=America/Los_Angeles
source /workspace/venv/bin/activate
apt-get update
apt-get install -y ffmpeg
pip install ffmpeg-python
cd /workspace/MAGI-1
通过以上步骤,可以确保MAGI-1项目在Runpod平台上正确部署和运行。对于不同的模型规模,只需调整相应的下载和配置参数即可。
登录后查看全文
热门项目推荐
相关项目推荐
atomcodeClaude Code 的开源替代方案。连接任意大模型,编辑代码,运行命令,自动验证 — 全自动执行。用 Rust 构建,极致性能。 | An open-source alternative to Claude Code. Connect any LLM, edit code, run commands, and verify changes — autonomously. Built in Rust for speed. Get StartedRust0218
cann-learning-hubCANN 学习中心仓,支持在线互动运行、边学边练,提供教程、示例与优化方案,一站式助力昇腾开发者快速上手。Jupyter Notebook0140
uni-appA cross-platform framework using Vue.jsJavaScript09
GLM-5.2智谱开源 GLM-5.2,这是针对长文本任务的最新旗舰模型。相较于前代产品 GLM-5.1,它在长文本任务处理能力上实现了显著飞跃,并且首次在稳定的 100 万 token 上下文中提供这一能力。Jinja00
SwanLab⚡️SwanLab - an open-source, modern-design AI training tracking and visualization tool. Supports Cloud / Self-hosted use. Integrated with PyTorch / Transformers / LLaMA Factory / veRL/ Swift / Ultralytics / MMEngine / Keras etc.Python00
tiny-universe《大模型白盒子构建指南》:一个全手搓的Tiny-UniverseJupyter Notebook03
项目优选
收起
openEuler内核是openEuler操作系统的核心,既是系统性能与稳定性的基石,也是连接处理器、设备与服务的桥梁。
C
471
466
deepin linux kernel
C
32
16
Claude Code 的开源替代方案。连接任意大模型,编辑代码,运行命令,自动验证 — 全自动执行。用 Rust 构建,极致性能。 | An open-source alternative to Claude Code. Connect any LLM, edit code, run commands, and verify changes — autonomously. Built in Rust for speed.
Get Started
Rust
2.09 K
218
本项目是CANN提供的神经网络类计算算子库,实现网络在NPU上加速计算。
C++
700
1.4 K
暂无描述
Dockerfile
780
5.08 K
Ascend Extension for PyTorch
Python
758
968
本仓库是 Flutter SDK 与 Flutter Engine 的 OpenHarmony 适配版本,由 CPF-Flutter 团队维护。开发者可使用熟悉的 Flutter 技术栈开发 OpenHarmony 应用,3.35.7 及以后的适配版本可基于本仓库源码构建支持 OpenHarmony 的 Flutter Engine。
Dart
1.04 K
271
本项目是CANN提供的transformer类大模型算子库,实现网络在NPU上加速计算。
C++
880
2.03 K
MindQuantum is a general software library supporting the development of applications for quantum computation.
Python
183
112
旨在打造算法先进、性能卓越、高效敏捷、安全可靠的密码套件,通过轻量级、可剪裁的软件技术架构满足各行业不同场景的多样化要求,让密码技术应用更简单,同时探索后量子等先进算法创新实践,构建密码前沿技术底座!
C
1.11 K
682