Win10 + CUDA11.3 + tf_GPU2.6.0 + pytorch_GPU1.10.1
- 软件版本
* - TensorFlow_GPU
- Pytorch_GPU
- 第一步:安装N卡驱动
- 第二步:安装Anaconda
- 第三步:CUDA、cuDNN的安装
* - CUDA11.3的安装
- cuDNN8.2.1的安装
- 验正安装结果
- 第四步:安装TensorFlow_GPU
- 第五步:安装Pytorch_GPU
- 相关参考
软件版本
个人N卡2070 super,驱动512.15,支持最新的CUDA11.6(方法:英伟达控制面板—>帮助—>系统信息—>组件)。但TensorFlow_GPU 2.6.0、Pytorch_GPU 1.11.0目前并未适配到CUDA11.6。
; TensorFlow_GPU
tf_ GPU 2.6.0 需搭配 CUDA11.2,cuDNN8.1,python3.6~3.9
; Pytorch_GPU
pytorch_GPU 1.11.0 支持 CUDA10.2、CUDA11.3
点击查看torch、torchvision、torchaudio版本对应关系
CUDACUDAToolkitPytorch11.311.31.11.0,1.10.1,1.10.0,1.9.1,1.9.0,1.8.111.111.11.8.011.011.01.7.1,1.7.010.210.21.11.0,1.10.1,1.10.0,1.9.1,1.9.0,1.8.1,1.8.0,1.7.1,1.7.0,1.6.0,1.5.1,1.5.010.110.11.7.1,1.7.0,1.6.0,1.5.1,1.5.0,1.4.010.010.01.2.0,1.1.0,1.0.1,1.0.09.29.21.7.1,1.7.0,1.6.0,1.5.1,1.5.0,1.4.0,1.2.09.09.01.1.0,1.0.1,1.0.08.08.01.0.0
尝试了 tf_GPU=2.6.0、CUDA=11.2、cuDNN=8.2.0、pytorch_GPU=1.8.0 or 1.10.1,结果 tf 没问题,pytorch总失败。最后安装 tf_GPU=2.6.0、CUDA=11.3、cuDNN=8.2.1、pytorch_GPU=1.10.1 两个都成功。
第一步:安装N卡驱动
官网下载对应显卡型号的驱动,注意带notebooks针对的是笔记本电脑。安装位置可自定义,也可默认。
第二步:安装Anaconda
(1)官网下载
Windows 64bit(对应操作系统位数)
(2)以管理员运行
; 第三步:CUDA、cuDNN的安装
CUDA11.3的安装
(1) 官网 下载CUDA11.3
(2)exe文件以管理员身份运行
安装程序显示NVIDIA程序已完成时,下边的 launch xxxx不要选中,随后点击关闭。因已装好,不想卸载重装,所以下图来自
此链接。
; cuDNN8.2.1的安装
(1)官网 下载cuDNN8.2.1
注:需登陆英伟达账号后才能下cuDNN
(2)解压cuDNN8.2.1,并重新命名
(3)复制
(4)添加环境变量
; 验正安装结果
参考博主花花少年的安装验证过程
; 第四步:安装TensorFlow_GPU
(1)打开cmd,激活conda,切换成国内清华镜像源
(2)创建tf_gpu环境并激活(Anaconda常用指令 )
conda activate
conda create -n tf_gpu python=3.9
conda activate tf_gpu
(3)安装TensorFlow GPU 2.6.0
conda install tensorflow-gpu=2.6.0
import tensorflow as tf
tf.__version__
tf.test.is_gpu_available()
(4)测试
参考链接,注意只有run time第二个数据远小于第一个数据,才表明GPU发挥了作用
(5)卸载Tensorflow
如果有卸载的需求,在tf_gpu环境中输入以下代码即可
conda uninstall tensorflow
第五步:安装Pytorch_GPU
安装torch的过程是最艰难的,个人先装的torch,然后装的tf。torch试过原地址装1.11.0(CUDA11.3时);1.10.1和1.8.0(CUDA11.2时),也试过换成清华源安装,但都False。有两个问题:1.原地址装,速度过慢,经常失败;2.无论是原地址或清华源装,总装成CPU版本的。多次尝试后,清华源装1.10.1没问题。
(1)打开cmd,激活conda,切换成国内清华镜像源
装TensorFlow_GPU已经换过源的,直接下一步
(2)创建pytorch_gpu环境并激活(想同时用 tf 和 pytorch,直接装在tf_gpu环境中,两个都能用的)
conda activate
conda create -n pytorch_gpu python=3.9
conda activate pytorch_gpu
(3)安装Pytorch GPU 1.10.1
官网给出的指令如下:
conda install pytorch==1.10.1 torchvision==0.11.2 torchaudio==0.10.1 cudatoolkit=11.3 -c pytorch -c conda-forge
其中 -c pytorch -c conda-forge 会在原地址下载,不是在配置好的清华源下载。因此,在安装时,pytorch_gpu环境中输入的指令为:
conda install pytorch==1.10.1 torchvision==0.11.2 torchaudio==0.10.1 cudatoolkit=11.3
import torch
torch.__version__
torch.cuda.is_available()
(4)卸载 Pytorch GPU
conda uninstall pytorch
(5)TensorFlow GPU和Pytorch GPU装在同一个环境下的验证
相关参考
1. https://www.bilibili.com/video/BV1ov41137Z8?p=1
2. https://blog.csdn.net/shiwanghualuo/article/details/122860521
3. https://blog.csdn.net/m0_37605642/article/details/99100924
4. https://blog.csdn.net/scl52tg/article/details/120959893
5. https://blog.csdn.net/qq_32390983/article/details/122257576
6. https://blog.csdn.net/wq3095435422/article/details/123534237?spm=1001.2101.3001.6650.4&utm_medium=distribute.pc_relevant.none-task-blog-2defaultCTRLISTRate-4.pc_relevant_antiscanv2&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2defaultCTRLISTRate-4.pc_relevant_antiscanv2&utm_relevant_index=8
7. https://blog.csdn.net/Williamcsj/article/details/123915652
8. https://blog.csdn.net/zxm_jimin/article/details/120966625
9. https://blog.csdn.net/zxm_jimin/article/details/120980192
Original: https://blog.csdn.net/xiao_yun_zi/article/details/124046964
Author: xiao_yun_zi
Title: Win10下 anaconda3 + cuda11.3 + TensorFlow_GPU2.6.0 + Pytorch_GPU1.10.1
相关阅读
Title: Pandas常用累计、同比、环比等统计方法实践案例
统计表中常常以本年累计、上年同期(累计)、当期(例如当月)完成、上月完成为统计数据,并进行同比、环比分析。如下月报统计表所示样例,本文将使用Python Pandas工具进行统计。
其中:
- (本年)累计:是指本年1月到截止月份的合计数
- (上年)同期(累计):是指去年1月到与本年累计所对应截止月份的合计数
- 同比(增长率)=(本期数-同期数)/同期数*100%
- 环比(增长率)=(本期数-上期数)/上期数*100%
注:这里的本期是指本月完成或当月完成,上期数是指上月完成。
示例数据:
注:为了演示方便,本案例数据源仅使用2年,且每年5个月的数据。
; 1. (本年)累计
在统计分析的发展中,按年和按月积累一些统计数据是相当常见的。对于数据,就是按规则逐行累计数据。
[En]
In the development of statistical analysis, it is quite common to accumulate some statistical data on an annual and monthly basis. For data, it is to accumulate data row by row according to the rules.
Pandas中的cumsum()函数可以实现按某时间维度累计需求。
import pandas as pd
df = pd.read_csv('data2021.csv')
cum_columns_name = ['cum_churncount','cum_newcount']
df[cum_columns_name] = df[['years','churncount','newcount']].groupby(['years']).cumsum()
注:其中分组'years'是指年度时间维度累计。
计算结果如下:
2. (上年)同期累计
对于(上年)同期累计,将直接取上一年度累计值的同月份数据。pandas DataFrame.shift()函数可以把数据移动指定的行数。
接续上列,读取同期数据。首先是把'yearmonth'上移五行,如上图所示得到新的DataFrame,通过'yearmonth'进行两表数据关联(左关联:左侧为原表,右侧为移动后的新表),实现去同期数据效果。
cum_columns_dict = {'cum_churncount':'cum_same_period_churncount',
'cum_newcount':'cum_same_period_newcount'}
df_cum_same_period = df[['cum_churncount','cum_newcount','yearmonth']].copy()
df_cum_same_period = df_cum_same_period.rename(columns=cum_columns_dict)
df_cum_same_period.loc[:,'yearmonth'] = df_cum_same_period['yearmonth'].shift(-5)
df = pd.merge(left=df,right=df_cum_same_period,on='yearmonth',how='left')
3. 上月(完成)
取上月的数据,使用pandas DataFrame.shift()函数把数据移动指定的行数。
接续上列,读取上期数据。(与取同期原理一样,略)
last_mnoth_columns_dict = {'churncount':'last_month_churncount',
'newcount':'last_month_newcount'}
df_last_month = df[['churncount','newcount','yearmonth']].copy()
df_last_month = df_last_month.rename(columns=last_mnoth_columns_dict)
df_last_month.loc[:,'yearmonth'] = df_last_month['yearmonth'].shift(-1)
df = pd.merge(left=df,right=df_last_month,on='yearmonth',how='left')
4. 同比(增长率)
计算同比涉及到除法,需要剔除除数为零的数据。
df.fillna(0,inplace=True)
df.loc[df['cum_same_period_churncount']!=0,'cum_churncount_rat'] = (df['cum_churncount']-df['cum_same_period_churncount'])/df['cum_same_period_churncount']
df.loc[df['cum_same_period_newcount']!=0,'cum_newcount_rat'] = (df['cum_newcount']-df['cum_same_period_newcount'])/df['cum_same_period_newcount']
df[['yearmonth','cum_churncount','cum_newcount','cum_same_period_churncount','cum_same_period_newcount','cum_churncount_rat','cum_newcount_rat']]
5. 环比(增长率)
df.loc[df['last_month_churncount']!=0,'churncount_rat'] = (df['churncount']-df['last_month_churncount'])/df['last_month_churncount']
df.loc[df['last_month_newcount']!=0,'newcount_rat'] = (df['newcount']-df['last_month_newcount'])/df['last_month_newcount']
df[['yearmonth','churncount','newcount','last_month_churncount','last_month_newcount','churncount_rat','newcount_rat']]
6. 总结
pandas做统计计算功能方法比较多,这里总结用到的技术有累计cumsum()函数、移动数据shift()函数、表合并关联merge()函数,以及通过loc条件修改数据。
Original: https://blog.csdn.net/xiaoyw/article/details/122979421
Author: 肖永威
Title: Pandas常用累计、同比、环比等统计方法实践案例

opencv位运算,cv2.bitwise_and,cv2.bitwise_or,cv2.bitwise_not,cv2.bitwise_xor

强化学习,直接策略搜索,策略梯度,入门样例

软件成分分析:华为云重磅发布开源软件治理服务

关于win7阉割版pycharm pyttsx3库无法使用解决方法

ModuleNotFoundError: No module named ‘tensorflow.examples‘

【Keras】保存模型的前几层,删除最后几层

基于docker的tensorflow2 bert 新闻分类模型部署

从决策辅助者到决策制定者 — CHRO新角色

YOLOP个人数据代码复现

日期中带的 T 是什么意思

arm64/x64/x86/macos安装tensorflow c语言版本

关于下载cuda和cudnn官方网站访问不了的替代方案

【语音识别】基于动态时间规整(DTW)的孤立字语音识别Matlab源码

关于Keras、tensorflow1.15的一点使用经验总结
