主页 > 人工智能  > 

[python]windows上安装yolov12环境

[python]windows上安装yolov12环境

yolov12出来了,地址github /sunsmarterjie/yolov12,咱们看看怎么在windows上把环境安装一下首先看看官方安装流程:

wget github /Dao-AILab/flash-attention/releases/download/v2.7.3/flash_attn-2.7.3+cu11torch2.2cxx11abiFALSE-cp311-cp311-linux_x86_64.whl conda create -n yolov12 python=3.11 conda activate yolov12 pip install -r requirements.txt pip install -e .

很明显官方只能在linux上安装,因为flash_attn这个是linux上的whl,然后去flash-attention源码页面的release找下有没有win_amd64.whl。很遗憾这个官方都是直接提供linux上的whl,windows上官方不直接支持。因此要么从其他途径找windows上的whl要么从源码编译。我试了下从源码开始有点难度,所以还是从其他地方找到whl,比如gitee /FIRC/flash_attn_chinese_mirror,当然您也可以去其他地址找一下。

我安装的是python3.10版本环境,大家也可以安装python3.11或者其他环境

conda create -n yolov12 python=3.10 conda activate yolov12

我下载了flash_attn-2.7.4+cu124torch2.5.1cxx11abiFALSE-cp310-cp310-win_amd64.whl

为了匹配对应版本我更换了torch版本。安装如下

pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url download.pytorch.org/whl/cu124

注释掉官方requirements.txt里面torch和flash-attn

#torch==2.5.1 #torchvision==0.20.1 #flash_attn-2.7.3+cu11torch2.2cxx11abiFALSE-cp311-cp311-linux_x86_64.whl timm==1.0.14 albumentations==2.0.4 onnx==1.14.0 onnxruntime==1.15.1 pycocotools==2.0.7 PyYAML==6.0.1 scipy==1.13.0 onnxslim==0.1.31 onnxruntime-gpu==1.18.0 gradio==4.44.1 opencv-python==4.9.0.80 psutil==5.9.8 py-cpuinfo==9.0.0 huggingface-hub==0.23.2 safetensors==0.4.3 numpy==1.26.4

pip install -r requirements.txt pip install -e . 

安装完成,接下来测试图片

yolo task=detect mode=predict model=weights/yolov12n.pt source=E:\animal.jpg save=true

FlashAttention is not available on this device. Using scaled_dot_product_attention instead. D:\anaconda3\envs\yolo12\lib\site-packages\timm\models\layers\__init__.py:48: FutureWarning: Importing from timm.models.layers is deprecated, please import via timm.layers warnings.warn(f"Importing from {__name__} is deprecated, please import via timm.layers", FutureWarning) Ultralytics 8.3.63 🚀 Python-3.10.16 torch-2.5.1+cu124 CUDA:0 (NVIDIA GeForce RTX 2070 Super, 8192MiB) YOLOv12n summary (fused): 352 layers, 2,590,824 parameters, 0 gradients, 6.5 GFLOPs image 1/1 E:\animal.jpg: 640x640 1 zebra, 1 giraffe, 16.0ms Speed: 4.0ms preprocess, 16.0ms inference, 91.0ms postprocess per image at shape (1, 3, 640, 640) Results saved to runs\detect\predict

上面提示FlashAttention is not available on this device,难道flash-attn没安装好?于是我定位源码

手动import

ok说明flash-attn安装没有问题,只能torch.cuda.get_device_capability()[0] >= 8不符合要求了。我电脑是RTX2070显卡,算力7.5,没有超过8,看起来flash-attn专门为算力>=8设计的模块?不过警告不用管直接查看

安装完成! 

标签:

[python]windows上安装yolov12环境由讯客互联人工智能栏目发布,感谢您对讯客互联的认可,以及对我们原创作品以及文章的青睐,非常欢迎各位朋友分享到个人网站或者朋友圈,但转载请说明文章出处“[python]windows上安装yolov12环境