三月十五号 anaconda 安装 tensorflow 教程
今天下载anaconda 并安装tensorflow
首先下载anaconda 因为官网下载特别慢 所有选择国内镜像网站 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/?C=M&O=A

找到最新版 windowx86_64下载 安装就可以了

这里选择上方的按钮 可以直接配置环境变量
安装好后 在开始菜单打开 Anaconda Prompt

接下来 依次 输入以下命令 不建议更换python 以及tensorflow的版本 因为可能有版本不支持
conda create -n TF2.1 python=3.7 conda activate TF2.1 conda install cudatoolkit=10.1 conda install cudnn=7.6 conda install -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/ tensorflow=2.5 python import tensorflow as tf
可能会出现一个错误 某版本过高 降低使用 当时是AL告诉我如果下载更低版本的 由于找不到了 就不做展示了
pycharm的安装跳过
在pycharm中配置解释器

新建一个项目 输入以下代码
import tensorflow as tf
tensorflow_version = tf.__version__
gpu_available = tf.test.is_gpu_available()
print("TensorFlow version:", tensorflow_version, "\tGPU available:", gpu_available)
a = tf.constant([1.0, 2.0], name="a")
b = tf.constant([1.0, 2.0], name="b")
result = tf.add(a, b, name="add")
print(result)
如果运行以下结果 说明安装成功

结果出现比较慢 可能在红字部分耐心等待几分钟

浙公网安备 33010602011771号