安装环境
不能使用conda安装pytorch,如果使用安装的conda可以让torch.cuda.is_available()为true,但是Ultralytics YOLOv8 还是显示无法使用GPU!
- 在虚拟环境安装yolov8,并激活
- 安装requirements.txt里面的包,但是注释掉torch,因为默认安装的为cpu版本
# Ultralytics requirements
# Usage: pip install -r requirements.txt
# Base ----------------------------------------
matplotlib>=3.2.2
numpy>=1.18.5
opencv-python>=4.1.1
Pillow>=7.1.2
PyYAML>=5.3.1
requests>=2.23.0
scipy>=1.4.1
# torch>=1.7.0
# torchvision>=0.8.1
tqdm>=4.64.0
# Logging -------------------------------------
tensorboard>=2.4.1
# clearml
# comet
# Plotting ------------------------------------
pandas>=1.1.4
seaborn>=0.11.0
# Export --------------------------------------
# coremltools>=6.0 # CoreML export
# onnx>=1.12.0 # ONNX export
# onnx-simplifier>=0.4.1 # ONNX simplifier
# nvidia-pyindex # TensorRT export
# nvidia-tensorrt # TensorRT export
# scikit-learn==0.19.2 # CoreML quantization
# tensorflow>=2.4.1 # TF exports (-cpu, -aarch64, -macos)
# tensorflowjs>=3.9.0 # TF.js export
# openvino-dev # OpenVINO export
# Extras --------------------------------------
ipython # interactive notebook
psutil # system utilization
thop>=0.1.1 # FLOPs computation
# albumentations>=1.0.3
# pycocotools>=2.0.6 # COCO mAP
# roboflow
# HUB -----------------------------------------
GitPython>=3.1.24
创建requirements.txt并安装
pip install -r requirements.txt
到pytorch官网使用pip命令安装torch
pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117
pip list一下,如果torch后面不显示cu,那就表明装的是cpu版本,卸载torch,重新运行上面命令安装torch,再装多一次就是带cuda的torch了
torch 1.13.1+cu117
torchaudio 0.13.1+cu117
torchvision 0.14.1+cu117
训练过程
指定device=0参数是,报错文章来源:https://www.toymoban.com/news/detail-630209.html
TypeError: replace expected at least 2 arguments, got 1
定位到错行,并注释报错的行文章来源地址https://www.toymoban.com/news/detail-630209.html
v = v.replace(" ", "").replace('') # handle device=[0, 1, 2, 3]
到了这里,关于yolov8训练环境安装一些坑的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!