【创作赢红包】安装cuda、配置环境、安装依赖统统教给你

安装cuda

  1. 百度网盘下载:
    在这里插入图片描述
    链接:https://pan.baidu.com/s/1CMcxnSxZ_W50UKTc-ROyzQ
    提取码:bdi1
  2. 点击exe,这个路径不要改
    在这里插入图片描述
  3. 同意
    在这里插入图片描述
  4. 自定义

在这里插入图片描述

  1. 不点VS那个选项,并且Driver components和Other components也不勾选。
    在这里插入图片描述

  2. 下一步
    在这里插入图片描述

  3. 等待一段时间后会出现下图,点击下一步
    在这里插入图片描述

  4. 环境变量
    在这里插入图片描述

  5. 压缩包解压后:
    在这里插入图片描述

  6. 解压出来的文件都复制到对应的目录下面
    在这里插入图片描述

  7. 查看
    在路径C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.1\extras\demo_suite中,用cmd运行bandwidthTest.exedeviceQuery.exe

在这里插入图片描述

创建虚拟环境

没有权限就去用管理员运行

  1. 安装好anaconda之后点击下图。进入base环境
    在这里插入图片描述
  2. 查看当前存在的虚拟环境conda env list
    在这里插入图片描述
  3. 创建虚拟环境
conda create -n py38 python=3.8
# conda create -n + 拟创建的虚拟环境名称 指定python环境(可选)

# 创建到指定目录下
conda create --prefix=D:\Environment\Anaconda3\envs\py38 python=3.8

在这里插入图片描述
中间需要输入y
在这里插入图片描述
4. 激活环境和退出激活环境可以看下面的命令
在这里插入图片描述
这个是指定目录下的。
在这里插入图片描述
在这里插入图片描述

  1. 激活虚拟环境

激活虚拟环境(注意:“conda activate + 拟激活的虚拟环境名称”)

conda activate py38

在这里插入图片描述

  1. 退出虚拟环境
conda deactivate

查看本虚拟环境下存在的

conda list

在这里插入图片描述

  1. 删除环境
conda remove -n env_name(自己的环境名字) --all

在这里插入图片描述

配置环境

  1. pycharm中配置

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
找到自己的虚拟环境位置进行配置即可。

安装依赖

(base) D:\ayj\code\ECG_Classification-main>conda activate py38

(py38) D:\ayj\code\ECG_Classification-main>pip install -r requirements.txt -i "https://pypi.tuna.tsinghua.edu.cn/simple/"

但是我在运行的时候发现有问题,使用国内镜像安装

pip install -r requirements.txt

pip install -r requirements.txt -i https://pypi.douban.com/simple/

安装torch

官网:https://pytorch.org/get-started/previous-versions/

  1. cmd中命令安装
>conda install pytorch==1.8.1 torchvision==0.9.1 torchaudio==0.8.1 cpuonly -c pytorch

在这里插入图片描述

  1. 安装CPU版
pip install torch==1.8.1+cpu torchvision==0.9.1+cpu torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html
  1. 我通过这个安装成功的
pip install torch==1.8.1+cu111 -f  https://download.pytorch.org/whl/cu111/torch_stable.html

在这里插入图片描述

国内镜像源

清华大学:https://pypi.tuna.tsinghua.edu.cn/simple
中国科学技术大学 : https://pypi.mirrors.ustc.edu.cn/simple
豆瓣:http://pypi.douban.com/simple/
阿里云:http://mirrors.aliyun.com/pypi/simple/

出现安全问题就将 http 改成 https

报错

镜像安全 http->https

(py38) D:\ayj\code\ECG_Classification-main>pip install -r requirements.txt -i http://pypi.douban.com/simple/
Looking in indexes: http://pypi.douban.com/simple/
WARNING: The repository located at pypi.douban.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommend you use HTTPS instead, otherwise you may silence this warning and allow
it anyway with ‘–trusted-host pypi.douban.com’.
ERROR: Could not find a version that satisfies the requirement scipy>=1.4.1 (from versions: none)
ERROR: No matching distribution found for scipy>=1.4.1
在这里插入图片描述

将这个http://pypi.douban.com/simple/ 换成 https://pypi.douban.com/simple/

torch+cu111

ERROR: Could not find a version that satisfies the requirement torch1.8.1+cu111 (from versions: 1.7.1, 1.8.0, 1.8.1, 1.9.0, 1.9.1, 1.10.0, 1.10.1, 1.10.2, 1.11.0, 1.12.0, 1.12.1, 1.13.0, 1.13.1, 2.0.0)
ERROR: No matching distribution found for torch
1.8.1+cu111
在这里插入图片描述

镜像源不对,修改成下面的。

pip install torch==1.8.1+cu111 -f  https://download.pytorch.org/whl/cu111/torch_stable.html

在这里插入图片描述

此时还有问题。可以直接下载到本地,然后从本地进行pip
例如我需要的是1.8.1+cu111
下载链接:https://download.pytorch.org/whl/cu111/torch-1.8.1%2Bcu111-cp38-cp38-win_amd64.whl
下载到本地(我的文件下载到了 D:\Environment)后

(base) D:\ayj\code\ECG_Classification-main>conda activate py38
(py38) D:\ayj\code\ECG_Classification-main>cd D:\Environment
(py38) D:\Environment>pip install "torch-1.8.1+cu111-cp38-cp38-win_amd64.whl"

在这里插入图片描述

内存不够

ERROR: Could not install packages due to an OSError: [Errno 28] No space left on device

清理C盘。

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

秦 羽

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值