当前位置: 首页 > news >正文

从零开始使用Intel的AIPC使用xpu加速comfyui

Intel的AIPC使用xpu加速跑comfyui

  • 环境安装
    • python环境搭建
    • 驱动及oneAPI安装
    • 创建python环境
    • 验证环境是否生效
  • ComfyUI的安装
    • 下载、汉化comfyui
    • 下载checkpoint
  • 测试
    • 使用xpu加速测试
    • 使用cpu执行测试

环境安装

python环境搭建

直接下载Anaconda 下载地址
在这里插入图片描述
安装好后,通过命令行设置清华源

conda config --set show_channel_urls yes

接着添加清华源

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/

驱动及oneAPI安装

参考官方连接
注意做到2.2即可,如果接着做可能会验证不通过

创建python环境

conda create -n comfy python=3.11 libuv
conda activate comfy
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

然后根据平台选择安装环境

# For Intel® Arc™ A-Series Graphics, use the commands below:
python -m pip install torch==2.3.1.post0+cxx11.abi torchvision==0.18.1.post0+cxx11.abi torchaudio==2.3.1.post0+cxx11.abi intel-extension-for-pytorch==2.3.110.post0+xpu --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/# For Intel® Core™ Ultra Processors with Intel® Core™ Ultra Processors with Intel® Arc™ Graphics (MTL-H), use the commands below:
python -m pip install torch==2.3.1.post0+cxx11.abi torchvision==0.18.1.post0+cxx11.abi torchaudio==2.3.1.post0+cxx11.abi intel-extension-for-pytorch==2.3.110.post0+xpu --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/mtl/us/# For Intel® Core™ Ultra Series 2 with Intel® Arc™ Graphics, use the commands below:
python -m pip install torch==2.3.1.post0+cxx11.abi torchvision==0.18.1.post0+cxx11.abi torchaudio==2.3.1.post0+cxx11.abi intel-extension-for-pytorch==2.3.110.post0+xpu --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/lnl/us/

接下来写一个运行的脚本,保存成1.cmd放在用户目录下,这样每次cmd运行时,首先执行1.cmd就能激活该环境

set SYCL_CACHE_PERSISTENT=1
set BIGDL_LLM_XMX_DISABLED=1
##替换成anaconda安装的路径
call "C:/ProgramData/anaconda3/Scripts/activate.bat" comfy
call "C:/Program Files (x86)/Intel/oneAPI/setvars.bat"
echo "conda activate comfy"

在这里插入图片描述

验证环境是否生效

win+r 打开cmd,然后运行1.cmd
可以看到以下输出就是成功
在这里插入图片描述
接下来在命令行中打入如下命令

python -c "import torch; import intel_extension_for_pytorch as ipex; print(torch.__version__); print(ipex.__version__); [print(f'[{i}]: {torch.xpu.get_device_properties(i)}') for i in range(torch.xpu.device_count())];"

可以看到如下的输出代表环境搭建成功
在这里插入图片描述

ComfyUI的安装

下载、汉化comfyui

首先上面搭建的环境中

git clone https://github.com/comfyanonymous/ComfyUI.git  
cd ComfyUI
pip install -r requirements.txt
安装插件管理平台
cd custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Manager.git

相关的依赖安装好后就能运行comfyui了

命令行运行,可以看到使用的时xpu

python main.py --disable-cuda-malloc --use-split-cross-attention

在这里插入图片描述
接着浏览器打开http://127.0.0.1:8188,打开manager进行汉化
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
安装好后重启comfyui,进入系统设置,修改语言中文即可

下载checkpoint

使用下载工具下载该模型:连接

下载后放入ComfyUI\models\checkpoints目录下
在这里插入图片描述
到这里comfyUI搭建完成

测试

使用xpu加速测试

运行命令如下

python main.py --disable-cuda-malloc --use-split-cross-attention

使用默认的工作流输出一张图片,从图片中可以看到经过xpu加速后,一张出图的时间大概是5分钟
在这里插入图片描述

使用cpu执行测试

运行命令如下

python main.py --cpu

这个模式下,cpu执行非常慢,按这个估算,估计要1个多小时在这里插入图片描述

http://www.lryc.cn/news/483180.html

相关文章:

  • PyQt入门指南五十二 版本控制与协作开发
  • 思考:linux Vi Vim 编辑器的简明原理,与快速用法之《 7 字真言 》@ “鱼爱返 说 温泉啊“ (**)
  • 共筑开源技术新篇章 | 2024 CCF中国开源大会盛大开幕
  • SpringBoot(十八)SpringBoot集成Minio
  • ODOO学习笔记(3):Odoo和Django的区别是什么?
  • 持续收集解决VCcode各种报错的方法
  • Windows下使用adb实现在模拟器中ping
  • c++之deque和priority_queue
  • SDL渲染器和纹理
  • 基于Matlab 火焰识别技术
  • Qt 监控USB设备的插入和移除
  • 终于弄懂了Python自定义模块与代码复用
  • 从无音响Windows 端到 有音响macOS 端实时音频传输播放
  • 直方图均衡化及Matlab实现
  • 设备接入到NVR管理平台EasyNVR多品牌NVR管理工具/设备的音视频配置参考
  • 后端:Aop 面向切面编程
  • 大数据机器学习算法与计算机视觉应用02:线性规划
  • godot——主题、Theme、StyleBox
  • 深入理解接口测试:实用指南与最佳实践5.0(一)
  • SQL面试题——飞猪SQL面试 重点用户
  • Angular 和 Vue2.0 对比
  • websocket服务器(协程风格)--swoole进阶篇
  • Windows C/C++ Socket 编程
  • 计算两个结构的乘法
  • 学校服务器连接pycharm配置2
  • AI赋能电商:创新应用提升销售与用户体验
  • 详解kafka消息发送重试机制的案例
  • linux文本管理!!!
  • 软件设计师-计算机体系结构分类
  • 《基于深度学习的车辆行驶三维环境双目感知方法研究》