win11+RTX3060+tensorflow2.7.0+python3.8+cuda11.6+cudann8.3.3

一、下载anaconda3的最新版本

Anaconda | The World's Most Popular Data Science PlatformAnaconda is the birthplace of Python data science. We are a movement of data scientists, data-driven enterprises, and open source communities.https://www.anaconda.com/1.1创建tensroflow-gpu版本的环境:

conda create --name tfgpu27 python=3.8

将环境激活:

conda activate tfgpu27

1.2为了方便后面的安装效率,更换国内镜像源:

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/conda-forge
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/pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes

1.3安装tensorflow gpu版本:

pip install tensorflow-gpu==2.7.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

如果清华源安装不上,则用豆瓣源安装:

pip install tensorflow==2.7.0 -i https://pypi.douban.com/simple/

二、安装CUDA和CUDANN

2.1 cuda下载11.6

CUDA Toolkit 11.6 Downloads | NVIDIA DeveloperResources CUDA Documentation/Release NotesMacOS Tools Training Sample Code Forums Archive of Previous CUDA Releases FAQ Open Source PackagesSubmit a BugTarball and Zip Archive Deliverableshttps://developer.nvidia.com/cuda-11-6-0-download-archivewin11+RTX3060+tensorflow2.7.0+python3.8+cuda11.6+cudann8.3.3_第1张图片

 经过解压后安装,原则为低版本和相同版本的不选择,只选择新版本的。如果选择Visual Studio 会安装vs。

安装完成后在cmd输入下面命令查看是否安装成功:

nvcc -V

2.2 cudann下载8.3.3

https://developer.nvidia.cn/rdp/cudnn-archiveicon-default.png?t=M666https://developer.nvidia.cn/rdp/cudnn-archive将cudann解压缩后的三个子文件夹下的子文件复制到cuda安装路径的对应名称的文件夹下,并非替换文件夹。

win11+RTX3060+tensorflow2.7.0+python3.8+cuda11.6+cudann8.3.3_第2张图片

 将cudann复制过去的文件夹添加到系统变量中:

右击’我的电脑‘--高级系统设置--环境变量--系统变量--Path--添加那四个:

bin、lib、include、libnvvp

三、检验gpu版本是否安装成功:

import tensorflow as tf
print(tf.test.is_gpu_available())

四、修改jupyter nootbook 的默认路径:

首先win+r寻找文件夹路径:

jupyter notebook --generate-config

ctrl+f 寻找位置,并将需要的路径添加到引号中:

c.NotebookApp.notebook_dir = ''

在图标上右击属性,将目标最后的双引号里的内容修改为新的路径即可。

三、在pycharm和vs code中配置tensorflow环境

后续。。。。。。

你可能感兴趣的:(tensorflow,python,深度学习)