安装cuda
- 百度网盘下载:
链接:https://pan.baidu.com/s/1CMcxnSxZ_W50UKTc-ROyzQ
提取码:bdi1 - 点击exe,这个路径不要改
- 同意
- 自定义
-
不点VS那个选项,并且Driver components和Other components也不勾选。
-
下一步
-
等待一段时间后会出现下图,点击下一步
-
环境变量
-
压缩包解压后:
-
解压出来的文件都复制到对应的目录下面
-
查看
在路径C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.1\extras\demo_suite
中,用cmd运行bandwidthTest.exe
和deviceQuery.exe
。
创建虚拟环境
没有权限就去用管理员运行
- 安装好anaconda之后点击下图。进入base环境
- 查看当前存在的虚拟环境
conda env list
- 创建虚拟环境
conda create -n py38 python=3.8
# conda create -n + 拟创建的虚拟环境名称 指定python环境(可选)
# 创建到指定目录下
conda create --prefix=D:\Environment\Anaconda3\envs\py38 python=3.8
中间需要输入y
4. 激活环境和退出激活环境可以看下面的命令
这个是指定目录下的。
- 激活虚拟环境
激活虚拟环境(注意:“conda activate + 拟激活的虚拟环境名称”)
conda activate py38
- 退出虚拟环境
conda deactivate
查看本虚拟环境下存在的
conda list
- 删除环境
conda remove -n env_name(自己的环境名字) --all
配置环境
- 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/
- cmd中命令安装
>conda install pytorch==1.8.1 torchvision==0.9.1 torchaudio==0.8.1 cpuonly -c pytorch
- 安装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
- 我通过这个安装成功的
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 torch1.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盘。