欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

在Windows 10系统和GTX 960显卡上成功安装并测试PyTorch的方法

最编程 2024-08-10 09:16:09
...

刚开始深度学习的入门,都推荐在linux环境下搭框架,先入门学习,就还是在windows下试试.
显卡是英伟达 NVIDIA GTX 960M,配置不高

anaconda选择的是 anaconda3
python是3.7.6

下面就是pytorch的安装。

前面的一些过程可以在B站或者其他的教程里找到。
在我进行搭环境时,最烦的是使用conda安装pytorch的缓慢,甚至直接中断,折腾了三四个小时.
后来使用清华镜像源进行安装,流畅舒服,十分钟搞定。
在anaconda的prompt中输入

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

将源换为清华镜像源。
最后运行下面的命令就可以快速安装好

conda install pytorch torchvision cudatoolkit=10.1

不过我在安装完,进行验证时报错: The NVIDIA driver on your system is too old (found version 9020). Please update your GPU driver by downloading and installing a new version from the URL:
这里需要更新显卡驱动
去链接: 显卡驱动.根据自己的显卡系列寻找最新的显卡驱动,只需要找到自己显卡的型号,其他不需要改动,按照提示下载安装显卡驱动。
验证语句

import torch
print(torch.cuda.is_available())

验证语句也是在prompt中如下图:返回true,代表GPU版可用,否则出现错误
验证语句

推荐阅读