安装cuda+cudnn+torch+torchvision

很久很久没打开pycharm了,一打开还是配不出环境来。。。先放几个帮助比较大的链接吧
link1
pytorch官网
安装以前版本

查看最高可安装的cuda版本,在cmd命令行中输入:

nvidia-smi

在这里插入图片描述
本次决定安装CUDA11.6。我在终端输入:

conda install cudatoolkit=11.6

显示如下:

Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

  - cudatoolkit=11.6

Current channels:

  - http://mirrors.aliyun.com/pypi/simple/win-64
  - http://mirrors.aliyun.com/pypi/simple/noarch
  - http://pypi.douban.com/simple/win-64
  - http://pypi.douban.com/simple/noarch
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch
  - https://mirrors.bfsu.edu.cn/anaconda/cloud/pytorch/win-64
  - https://mirrors.bfsu.edu.cn/anaconda/cloud/pytorch/noarch
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/free/win-64
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/free/noarch
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/main/win-64
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/main/noarch
  - https://mirrors.bfsu.edu.cn/anaconda/cloud/conda-forge/win-64
  - https://mirrors.bfsu.edu.cn/anaconda/cloud/conda-forge/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.

按照一些博主所说的,查看可以安装的cuda版本:

conda search cudatoolkit

显示依然如下:

Loading channels: done
No match found for: cudatoolkit. Search: *cudatoolkit*

PackagesNotFoundError: The following packages are not available from current channels:

  - cudatoolkit

Current channels:

  - http://mirrors.aliyun.com/pypi/simple/win-64
  - http://mirrors.aliyun.com/pypi/simple/noarch
  - http://pypi.douban.com/simple/win-64
  - http://pypi.douban.com/simple/noarch
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch
  - https://mirrors.bfsu.edu.cn/anaconda/cloud/pytorch/win-64
  - https://mirrors.bfsu.edu.cn/anaconda/cloud/pytorch/noarch
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/free/win-64
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/free/noarch
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/main/win-64
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/main/noarch
  - https://mirrors.bfsu.edu.cn/anaconda/cloud/conda-forge/win-64
  - https://mirrors.bfsu.edu.cn/anaconda/cloud/conda-forge/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.

试了很多命令显示都是这样。
后来我按照link1中给出的方法,将原来的 .condarc 中的内容更新如下:

channels:
  - defaults
show_channel_urls: true
default_channels:
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
custom_channels:
  conda-forge: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

终于不再出现那个问题了。
接下来我在pytorch官网中查看 CUDA11.6 可以安装的 torch 版本:
在这里插入图片描述
然后在终端中执行命令。很久之后安装好了。
上述库都是使用 conda 命令安装成功的。接下来我又安装了 opencv-python,这时用 conda 命令怎么也安不上,但是改为 pip 命令就成功了。随后又安装了 opencv-contrib-python,也是使用 pip 命令一次就成功了。

顺便记录下我安装其他库的一些过程。
首先是运行代码时出现了如下错误:

ImportError: cannot import name ‘OrderedDict‘ from ‘typing‘ (D:\Anaconda\lib\typing.py)

解决方案如这位大佬所述

紧接着又出现了如下错误:

ModuleNotFoundError: No module named 'lmdb'

按照这位大佬的方法解决

紧接着又出现了这个问题:

cv2.error: OpenCV(3.4.14) C:\surf.cpp:1029: error: (-213:The function/feature is not implemented) This algorithm is patented and is excluded in this configuration; Set OPENCV_ENABLE_NONFREE CMake option and rebuild the library in function 'cv::xfeatures2d::SURF::create'

看了一些帖子,说是 opencv-contrib-python 3.4 以上的版本都不支持 cv2.xfeatures2d 接口了。有一些高版本的解决方案,但我选择卸载重新安装低版本的 opencv-python 和 opencv-contrib-python。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值