前言
tensorflow 由google发布开源的机器学习框架,2.x 是在1.x上基础上简化,重点关注易用性,同时兼具可扩展性和高性能,降低了机器学习的门槛。
1:环境
win10
Anaconda3-2022.05-Windows-x86_64 下载地址 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/?C=M&O=D
或 https://repo.anaconda.com/archive/
pycharm-community-2022.2.3 下载地址:自行下载
推荐教程地址:https://tf.wiki/zh_hans/foreword.html
2:搭建
1> 创建环境
安装 Anaconda3 并将anaconda添加至环境变量
创建虚拟环境: 参考:https://tensorflow.google.cn/install/source_windows#gpu
conda create -n tf2 python==3.9.12
或 conda create --prefix=D:/tensorflow/tf2 python=3.9.12 (指定位置,这样更好)
*****显卡驱动版本一定要大于等于cuda版本
****在桌面上右键——NVIDIA控制面板——帮助——系统信息
激活环境:activate tf2 或 activate D:/tensorflow/tf2
以txt形式打开"C:\Users(你的用户名).condarc"文件,将内部文本替换为以下文本
替换为清华源或其他源
channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
安装GPU版本
conda install tensorflow-gpu2.6.0 或
pip install tensorflow-gpu2.6.0
查看安装是否成功
conda list tensorflow
安装 pycharm-community
配置环境