一、安装cuda和cudnn
1、安装cuda之前先打开英伟达控制面板查看自己的显卡信息
2、“帮助”—>“系统信息”—>“组件”,然后看第三行的信息“Nvidia CUDA 12.4”
3、进入英伟达官网“CUDA Toolkit Archive | NVIDIA Developer”,我的是12.4
下载完成后nvcc -V检查一下是否安装正确
nvcc -V
查看是否配置环境变量
二、下载CUDNN
cuDNN Archive | NVIDIA Developer
下载好了过后把解压出来放到CUDAv12.4安装目录下
然后配置环境变量
D:\daima\CUDAv12.4\bin
D:\daima\CUDAv12.4\extras\CUPTI\lib64
三、安装pytorch(带GPU)
PyTorch
1、
2、
3、找到这个,我的是12.4,安装12.1的也行
4、安装ultralytics
pip install ultralytics
5、因为ultralytics自带是cpu的我们需要卸载cpu版本的pytorch
pip uninstall torch
6、安装第三步复制的内容
conda install pytorch==2.2.2 torchvision==0.17.2 torchaudio==2.2.2 pytorch-cuda=12.1 -c pytorch -c nvidia
7、可以测试一下了(如果不行看最下面)
import ultralytics
ultralytics.checks()
import torch
print(torch.__version__)
print(torch.cuda.is_available())
print(torch.cuda.device_count())
OK
安装后报错:ImportError: cannot import name 'COMMON_SAFE_ASCII_CHARACTERS' from 'charset_normalizer.constant' (D:\daima\anaconda3\yolo\lib\site-packages\charset_normalizer\constant.py)
pip install chardet
安装后报错:
raise RuntimeError('''
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module:
if __name__ == '__main__':
freeze_support()
...
The "freeze_support()" line can be omitted if the program
is not going to be frozen to produce an executable.
需要拿 if __name__ == '__main__':包起来
其它报错:建议测试把works调成1
YOLO5模型训练过程_mac训练yolov5-CSDN博客
YOLO5 6.1版本报错解决_ranges = np.round(np.linspace(8, 4, 10), 0).astype-CSDN博客