Dockerfile环境:
bash展开代码FROM dockerpull.org/pytorch/pytorch:2.4.0-cuda12.1-cudnn9-devel
RUN pip install diffusers -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
RUN pip install gradio uvicorn
RUN pip install transformers -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
RUN pip install accelerate sentencepiece ftfy openai -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
WORKDIR /app
COPY ./scripts /app/scripts
RUN chmod +x /app/scripts/entrypoint.sh
EXPOSE 7860
ENTRYPOINT ["/app/scripts/entrypoint.sh"]
在Ubuntu中卸载现有的NVIDIA驱动并安装指定的驱动文件,可以按照以下步骤操作:
首先,确保没有程序正在使用NVIDIA显卡驱动,推荐在纯文本模式下进行操作:
bash展开代码docker run -d --gpus device=3 \ -v /data/xiedong/LLaMA-Factory/output/checkpoint-20600:/data/xiedong/LLaMA-Factory/output/checkpoint-20600 \ -p 8005:8000 \ --ipc=host \ dockerpull.org/vllm/vllm-openai:latest \ --model /data/xiedong/LLaMA-Factory/output/checkpoint-20600 --gpu_memory_utilization=0.4
modelscope下载模型:
bash展开代码conda create -n modelscop
要保留最新的目录并删除其余的旧目录,可以使用以下步骤:
首先,找到最新的目录。根据你的目录结构,"checkpoint"后面跟随着数字,这些数字可以用来识别迄今为止最新的目录。
使用Linux命令来识别并删除旧目录。
bash展开代码# 进入包含 checkpoint 目录的路径
cd /app/saves/Qwen2.5-1.5B-Instruct/full/train_2024-11-06-10-03-45
# 找到最新的 checkpoint 目录
latest_checkpoint=$(ls -d checkpoint-* | sort -V | tail -n 1)
# 输出最新的目录,确认无误
echo "最新的检查点: $latest_checkpoint"
# 删除除了最新的检查点之外的所有目录
for dir in checkpoint-*; do
if [ "$dir" != "$latest_checkpoint" ]; then
rm -rf "$dir"
fi
done
上面的脚本使用 ls
和 sort
获取经过版本排序的所有检查点目录列表,然后用 tail -n 1
找到最新的目录。接着,它遍历所有的检查点目录,保留最新的一个,删除其他的。
请确保您在执行删除操作时非常小心,以避免数据丢失。
在现代计算中,利用多核CPU的能力来提高程序的性能已成为必不可少的技能。Python的multiprocessing
模块提供了简便的接口来实现多进程并行计算。本文将通过一个实际的代码示例,详细介绍如何使用Python的多进程来分发和处理任务。