当前位置: 首页 > news >正文

赶快收藏:快速安装PyTorch和TensorFlow(gpu+cpu+1.7.1+2.2.0--cuda_11.0.2_450.51.05)命令

如果有必要,记得先创建一个anaconda3虚拟环境:

onda create --name 环境名 python==3.7

cuda:

wget http://developer.download.nvidia.com/compute/cuda/11.0.2/local_installers/cuda_11.0.2_450.51.05_linux.run
sudo sh cuda_11.0.2_450.51.05_linux.run

PyTorch

豆瓣源:

 pip install torch===1.4.0 torchvision===0.5.0 -f https://download.pytorch.org/whl/torch_stable.html -i https://pypi.douban.com/simple some-package

或者1.7.0最新稳定版本:

pip install torch==1.7.1+cu101 torchvision==0.8.2+cu101 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html -i https://pypi.douban.com/simple some-package

https://pytorch.org/

或者
pip install torch=1.7.1 torchvision=0.8.2 torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html -i https://pypi.douban.com/simple some-package
清华源:

pip install torch===1.4.0 torchvision===0.5.0 -f https://download.pytorch.org/whl/torch_stable.html -i https://pypi.tuna.tsinghua.edu.cn/simple some-package

汇总:

pip install torch==1.7.1+cu110 torchvision==0.8.2+cu110 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html -i https://pypi.douban.com/simple some-package

pip install torch==1.7.1+cu110 torchvision==0.8.2+cu110 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html -i https://pypi.tuna.tsinghua.edu.cn/simple some-package

pip install torch==1.7.0+cu110 torchvision==0.8.1+cu110 torchaudio==0.7.0 -f https://download.pytorch.org/whl/torch_stable.html -i https://pypi.tuna.tsinghua.edu.cn/simple some-package

TensorFlow

pip install --index-url https://pypi.douban.com/simple tensorflow

或指定版本:

install --index-url https://pypi.douban.com/simple tensorflow==1.15.0

在这里插入图片描述

TF-gpu2.X

pip install --index-url https://pypi.douban.com/simple tensorflow-gpu==2

在这里插入图片描述

win10+cuda10.2安装pytorch1.7.1(使用清华镜像源)

(1)更换镜像源

在命令行中输入下述命令:

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/

备注:
(1)torch和torchvison下载地址
https://download.pytorch.org/whl/torch_stable.html
在这里插入图片描述

(2)安装相应的pytorch版本

conda install pytorch torchvision cudatoolkit=10.2

(版本号从https://pytorch.org/上,查找对应版本)

参考文献:
https://blog.csdn.net/liubing8609/article/details/113359885

解决其他慢的参考文献:
https://www.zhihu.com/question/435340249

其他详细教程:
配置清华镜像源
我们使用Anaconda环境进行Pytorch的安装

在命令行中依次输入一下命令并执行

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge 
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

设置搜索时显示通道地址

conda config --set show_channel_urls yes

安装Pytorch
使用清华镜像源进行Pytorch的安装时,官方给出的安装命令就失效了

官方给出的安装命令是:

conda install pytorch torchvision cudatoolkit=10.1 -c pytorch

如果使用清华镜像源安装Pytorch时,需要输入以下命令:

conda install pytorch torchvision cudatoolkit=10.1

在Linux上使用shell脚本一键安装
使用Linux系统的时候,有时一步一步复制粘贴命令非常麻烦,特别是使用远程服务器的时候。这时候就需要shell脚本一键解决复制粘贴命令的麻烦。

在任意文件目录下新建一个shell脚本文件,这里取名为 pytorch_install.sh

shell脚本文件的内容如下所示

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge 
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

设置搜索时显示通道地址

conda config --set show_channel_urls yes

安装pytorch

conda install pytorch torchvision cudatoolkit=10.1

在命令行中执行shell脚本,输入命令:

bash pytorch_install.sh
1
等待安装完成即可。

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • 2004年7月13日
  • Matlab使用笔记(十一):simulink模型仿真的时序数据类:timeseries
  • simulink中调用C语言进行仿真
  • 网站完工
  • 2021年完美安装YOLO教程:成功在Windows10下安装YOLO开发环境并成功完成目标检测测试「基于C/C++版本」
  • 2004年7月15日
  • Python使用高德地图绘制经纬度坐标位置
  • 2021年最新完整统计TensorFlow2.x报错记录与解决方法「希望能帮助到你」
  • 2004年7月16日
  • Release of the Data Access Application Block 3.1
  • 【长篇博文】Docker学习笔记与深度学习环境的搭建和部署(一)
  • 两个小时学会DirectDraw编程 (转载)
  • 【长篇博文】Docker学习笔记与深度学习环境的搭建和部署(二)
  • 从系统中取得指定资源图像(转载)
  • 【长篇博文】Docker学习笔记(四):镜像的分层、打包、双向绑定、导入导出、Dockerfile的构建、部署与发布
  • hexo+github搭建个人博客
  • download使用浅析
  • JavaScript 奇技淫巧
  • Java程序员幽默爆笑锦集
  • learning koa2.x
  • Lsb图片隐写
  • Map集合、散列表、红黑树介绍
  • Redis提升并发能力 | 从0开始构建SpringCloud微服务(2)
  • Vue 2.3、2.4 知识点小结
  • Zepto.js源码学习之二
  • 个人博客开发系列:评论功能之GitHub账号OAuth授权
  • 基于Volley网络库实现加载多种网络图片(包括GIF动态图片、圆形图片、普通图片)...
  • 检测对象或数组
  • 前端存储 - localStorage
  • 悄悄地说一个bug
  • 提醒我喝水chrome插件开发指南
  • elasticsearch-head插件安装
  • 不要一棍子打翻所有黑盒模型,其实可以让它们发挥作用 ...
  • 选择阿里云数据库HBase版十大理由
  • ​创新驱动,边缘计算领袖:亚马逊云科技海外服务器服务再进化
  • ​力扣解法汇总1802. 有界数组中指定下标处的最大值
  • # 详解 JS 中的事件循环、宏/微任务、Primise对象、定时器函数,以及其在工作中的应用和注意事项
  • #define
  • #ifdef 的技巧用法
  • #我与Java虚拟机的故事#连载15:完整阅读的第一本技术书籍
  • $.ajax()
  • (1)Hilt的基本概念和使用
  • (24)(24.1) FPV和仿真的机载OSD(三)
  • (八)五种元启发算法(DBO、LO、SWO、COA、LSO、KOA、GRO)求解无人机路径规划MATLAB
  • (搬运以学习)flask 上下文的实现
  • (多级缓存)多级缓存
  • (七)MySQL是如何将LRU链表的使用性能优化到极致的?
  • (收藏)Git和Repo扫盲——如何取得Android源代码
  • (五)c52学习之旅-静态数码管
  • (一)硬件制作--从零开始自制linux掌上电脑(F1C200S) <嵌入式项目>
  • (原)本想说脏话,奈何已放下
  • (转)MVC3 类型“System.Web.Mvc.ModelClientValidationRule”同时存在
  • (转)德国人的记事本
  • (转)真正的中国天气api接口xml,json(求加精) ...
  • .NET CF命令行调试器MDbg入门(一)