当前位置:   article > 正文

Windows系统上Anaconda创建虚拟环境安装cuda、cudnn、pytorch_windows下安装的cuda如何应用到conda中

windows下安装的cuda如何应用到conda中

一、Conda创建虚拟环境

指定虚拟环境名称(conda create -n xxxx)和python版本(python=x.x)

conda create -n mypytorch python=3.9

二、安装cuDNN 和CUDA

1.先更新显卡驱动

安装NVIDIA显卡驱动

直接进NVIDIA官网:NVIDIA GeForce 驱动程序 - N 卡驱动 | NVIDIA

2.激活环境conda activate mypytoch(自己设置的虚拟环境名称)

3.执行以下命令添加清华源到Anaconda的下载源加快下载速度

  1. conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  2. conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  3. conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  4. conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
  5. conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro/

4.输入以下代码,安装cuDNN和cuda

conda install cudnn

安装cuDNN的同时,conda会安装对应版本的CUDA

5.等待下载完成,查看安装结果

conda list

三、Anaconda安装Pytorch

Pytorch官网中选择对应版本,

红框显示先前版本,我的是cuda 11.1,寻找对应版本的cuda

复制到命令窗口

下载

问题

ERROR: No matching distribution found for torchyision==0.11.2+cu111

换一个CUDA11.1:

  1. pip install torch==1.9.1+cu111 torchvision==0.10.1+cu111 torchaudio==0.9.1 -f https://download.pytorch.org/whl/torch_stable.html

在python检验pytorch是否可用

  1. import torch
  2. print(torch.__version__) #查看pytorch版本
  3. print(torch.cuda.is_available()) #查看cuda是否可用 输出为True 或者False

​​​​​​​四、pycharm导入虚拟环境

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/398073
推荐阅读
相关标签
  

闽ICP备14008679号