Detected that PyTorch and torchvision were compiled with different CUDA version报错处理

报错原因:pytorch版本和torchvision版本不一致。

报错处理步骤:

一、需要先查看你的pytorch版本,我采用的是新建一个文件输出pytorch版本。

import torch
print(torch.__version__) 

这样就会打印你的pytorch版本。

二、找pytoch版本对应的torchvision版本,对照下面这个表去查。

Detected that PyTorch and torchvision were compiled with different CUDA version报错处理_第1张图片

我的pytorch版本四1.4.0所以对应需要安装torchvision的版本是0.5.0。

三、进入下面这个网址去找torchviosion版本文件https://download.pytorch.org/whl/torch_stable.html

同时,在下载文件的时候需要注意看一下自己python版本,查看python版本步骤如下:

(1)点开编译器下方的Terminal

 (2)输入python --version即可查看python版本

Detected that PyTorch and torchvision were compiled with different CUDA version报错处理_第2张图片

可以看到我的python版本是3.7。

然后找到pytorch版本对应的torchvision文件,我的是下面这个:

 其中0.5.0就是版本号,cp37就是python版本为3.7,win_amd64就是适合于windows 64位系统。

四、下载完之后把文件放入项目的根目录(比较方便)

Detected that PyTorch and torchvision were compiled with different CUDA version报错处理_第3张图片

五、打开Terminal输入pip install torchvision-0.5.0+cpu-cp37-cp37m-win_amd64.whl 安装完毕就不会报错啦✌。

你可能感兴趣的:(python)