深度学习之pytorch环境安装:win10-python3.9-cuda10.1-cudnn7.6.4-pytorch1.7.1
1.Anaconda+pycharm安装参考这篇博文:
Python开发环境搭建之安装Pycharm+Anaconda_python pycharm ancodan-CSDN博客文章浏览阅读1.5k次,点赞22次,收藏20次。python学习环境搭建,安装并配置Anaconda和Pycharm。_python pycharm ancodanhttps://blog.csdn.net/m0_56195839/article/details/137557499?spm=1001.2014.3001.5501
这是我的python版本:
C:\Users\xxx>python --version
Python 3.9.13
(1)Pycharm下载
1.下载社区版,社区版在后面,往下翻就能看到,一般来说都是选择exe(windows),看电脑配置。
2.Pytorch安装:
2.1 CUDA安装
参考博文:
我的主机显示CUDA Version:10.1
下载CUDA后以管理员身份运行,第一次会出现一个路径选择,我选择放在D盘,不过这个安装包在安装过后会自动删除,所以后面自定义的路径不要和这个重复也不要放在这个文件夹中。
安装过程中有疑问查看以下链接:
我的cuda安装历程_cuda可以安装到d盘吗-CSDN博客
CUDA安装成功!
2.2 cuDNN安装
最终输出如下,成功!
(torch) C:\Users\xx>conda list
# packages in environment at D:\xxx\Anaconda\envs\torch:
#
# Name Version Build Channel
ca-certificates 2024.11.26 haa95532_0 defaults
openssl 1.1.1w h2bbff1b_0 defaults
pip 24.2 py39haa95532_0 defaults
python 3.9.13 h6244533_2 defaults
setuptools 75.1.0 py39haa95532_0 defaults
sqlite 3.45.3 h2bbff1b_0 defaults
tzdata 2024b h04d1e81_0 defaults
vc 14.40 haa95532_2 defaults
vs2015_runtime 14.42.34433 h9531ae6_2 defaults
wheel 0.44.0 py39haa95532_0 defaults
3.pytorch安装
根据参考的博文我的pytorch没有安装成功。
根据以下参考博文:
下载三个whl文件:
pip后运行报错:
(torch) C:\Users\xx>python
Python 3.9.13 (main, Oct 13 2022, 21:23:06) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.2 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.
If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.
Traceback (most recent call last): File "<stdin>", line 1, in <module>
File "D:\xxx\__init__.py", line 190, in <module>
from torch._C import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\xxx\__init__.py", line 190, in <module>
from torch._C import *
AttributeError: _ARRAY_API not found
PyTorch 与 NumPy 2.0.2 不兼容
Pytorch 与 numpy、torchvision、torchaudio 和 torchtext 各个版本的兼容性列表_pytorch与numpy对应版本-CSDN博客
看到这篇博文,发现Numpy版本过高。应修改为合适范围。
更改Numpy的版本:
pip install numpy==1.19.5 --upgrade --force-reinstall
输出true,成功!
(torch) C:\Users\x>python
Python 3.9.13 (main, Oct 13 2022, 21:23:06) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.cuda.is_available()
True
>>> print(torch.__version__)
1.7.1+cu101
原文地址:https://blog.csdn.net/weixin_53036073/article/details/143800202
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!