当前位置:网站首页>初识Pytorch和Pytorch环境配置
初识Pytorch和Pytorch环境配置
2022-07-24 18:16:00 【Kang|King】
初识Pytorch和Pytorch环境配置
pytorch的发展与框架
深度学习框架的话,对我而言就是分为Tensorflow和Pytorch两大阵营。他们的主要区别就是静态图优先还是动态图优先。
动态图静态图
动态图:一步一步来,有结果而且符合人们的思维。
静态图:只有公式,然后最终把数据输入。这是一种分离的状态,定义好公式,run的时候直接输入数据使用且不能修改,即 define→run 的过程。
二者性能的对比

Tensorflow1和2不兼容给我整笑了,1的优势2无法继承了。
pytorch可以干什么?
pytorch可以GPU加速,自动求导,有常用网络层。
比如进行一个GPU的加速:
这里第一次使用Cuda为什么时间更长呢?因为需要初始化一些配置,要花费一定的时间,第二次可以看到明显时间更少了。
对于求导而言,代码如下:
# 赋值,告诉torch我需要求导
x = torch.tensor(1.)
a = torch.tensor(1., requires_grad=True)
b = torch.tensor(2., requires_grad=True)
c = torch.tensor(3., requires_grad=True)
...
grads = autograd.grad(y, [a,b,c])
# 求出来的a,b,c都是相应的导数
常用网络层:nn.Linear nn.Conv2d nn.LSTM和一些激活函数等等“函数”。
环境配置
由于我刚刚换的Y9000P,且是32G内存+512G+1T的固态,因此我什么都不怕!(bushi)
我配置的思路是在Anaconda上进行一个搭建。
- 安装Anaconda(python也会顺带安装好,里面需要注意的是path添加选项一定要点!!!)
- 找到自己显卡对应的版本,由于我的驱动已经安装好了,因此我不需要去官网进行安装或者更新,如有需要,先把Cuda安装好。
- 安装Cudnn
- 在Anaconda的Prompt里面创建名为Pytorch的环境
- 在Pytorch官网找到对应的版本,在激活了Pytorch环境之后,在其中进行对应语句的运行(因为你在官网选好版本之后,会有相应的运行语句的,复制到命令行即可)
- 我选择在jupyter notebook进行操作,在激活的环境下输入jupyter notebook即可跳转到相应界面。
遇到的问题
如何查看自己的显卡版本/如何查看自己CUDA版本?
解决方案:打开nvidia面板,帮助里面就有。
WARNING conda.gateways.disk.delete:unlink_or_rename_to_trash(140)
解决方案:csdn
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
解决方案:可能是相应限制时长太短;修改为清华源;直接把包下载好,离线本地安装。(或者你连Cudnn都没装)
边栏推荐
- web渗透经验汇总ing
- JS array method sort() collation parsing
- Model saving and loading of sklearn
- 颜色的13 个必备方法!
- undefined reference to H5PTopen
- [OBS] cooperation between video and audio coding and RTMP transmission
- 模拟实现vector
- Learn redisson from scratch ------- topics (subscription and distribution)
- Section 10 cache breakdown follow Daewoo redis ------- directory post
- Get the original data API on 1688app
猜你喜欢

How does win11 enhance the microphone? Win11 enhanced microphone settings

第五届数字中国建设峰会在福建福州开幕

Wechat applet

Inherit, override, overload

The 5th Digital China Construction summit opened in Fuzhou, Fujian

模拟实现vector

PXE高效批量网络装机

05mysql lock analysis

pycharm配置opencv库

Emerging potential of interactive virtual reality technology in drug discovery
随机推荐
Still building projects from scratch? This upgraded rapid development scaffold is worth a try!
0629~SaaS平台设计~全局异常处理
05mysql lock analysis
Flatten array.Flat (infinity)
What are the pitfalls from single architecture to distributed architecture?
New can also create objects. Why do you need factory mode?
【obs】依赖库: x264 vs 构建
颜色的13 个必备方法!
还在从零开始搭建项目?这款升级版快速开发脚手架值得一试!
sklearn 的模型保存与加载使用
JMeter -- prometheus+grafana server performance visualization
[OBS] dependency Library: x264 vs Build
0613 ~ self study
Example of single table query in ORM student management system
Win10 super good-looking mouse theme, you also try it
How to read "STL source code analysis"?
XSS绕过姿势总结
PXE efficient batch network installation
[opencv] - thresholding
文件上传漏洞——.user.ini与.htaccess