1. 安装
项目官网OpenVLA
首先按照官网提示的以下代码,执行创建环境->安装最小依赖->git克隆项目等
# Create and activate conda environment
conda create -n openvla python=3.10 -y
conda activate openvla# Install PyTorch. Below is a sample command to do this, but you should check the following link
# to find installation instructions that are specific to your compute platform:
# https://pytorch.org/get-started/locally/
conda install pytorch torchvision torchaudio pytorch-cuda=12.4 -c pytorch -c nvidia -y # UPDATE ME!# Clone and install the openvla repo
git clone https://github.com/openvla/openvla.git
cd openvla
pip install -e .# Install Flash Attention 2 for training (https://github.com/Dao-AILab/flash-attention)
# =>> If you run into difficulty, try `pip cache remove flash_attn` first
pip install packaging ninja
ninja --version; echo $? # Verify Ninja --> should return exit code "0"
pip install "flash-attn==2.5.5" --no-build-isolation
下载openvla-7b
模型到本地
从hugging face
镜像网站https://hf-mirror.com
上下载
我用的是AutoDL,所以想直接把模型下载到远程的服务器上,操作如下。
(1)安装工具huggingface-cli
pip install -U huggingface_hub
(2)创建python
脚本
import os
// 设置环境变量
os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'
// 下载模型
os.system('huggingface-cli download --resume-download HF上的模型名称 --local-dir 本地存放路径')
// 下载数据集
os.system('huggingface-cli download --repo-type dataset --resume-download HF上的数据集名称 --local-dir 本地存放路径')
例如,我只想下载openvla-7b
这个模型,脚本如下
import os
# // 设置环境变量
os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'
# // 下载模型
os.system('huggingface-cli download --resume-download openvla/openvla-7b --local-dir /root/openvla/openvla7b')
执行上述脚本即可下载模型到本地,即时镜像也需要挺长时间。
在运行过程中,出现磁盘空间不够的问题导致下载终止!需要注意autodl
中租用的实例中会自动分配30G系统盘+50G数据盘,如下图。其中/root/autodl-tmp
为数据盘,除此之外的都认为是系统盘,一般创建的环境可以默认在系统盘,但是项目源码特别是模型(通常几十个G)在下载存放时要注意路径,如果不小心将模型放到系统盘(容量非常小,只有30G),很可能导致下载终止浪费掉几个小时时间!
手动删除系统盘的模型文件后,最后再清理一下磁盘AutoDL清理磁盘