简单 TensorFlow 2 anaconda安装教程 示例

一、安装anaconda

https://www.anaconda.com/products/individual#Downloads
anaconda官网下载,安装即可
如果下载慢的话,更换到清华源
https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/

二、更换anaconda源

在Anaconda Prompt (Anaconda3)运行命令

conda config --set show_channel_urls yes

如图所示
在这里插入图片描述

编辑Windows 用户目录下的**.condarc**文件
简单 TensorFlow 2 anaconda安装教程 示例_第1张图片
粘贴如下并保存

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
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
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
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

在Anaconda Prompt (Anaconda3)运行命令

conda clean -i

如图所示
简单 TensorFlow 2 anaconda安装教程 示例_第2张图片

三 安装TensorFlow

在 Anaconda Powershell Prompt (Anaconda3)创建虚拟环境并进入

 conda create -n tensorFlow 

简单 TensorFlow 2 anaconda安装教程 示例_第3张图片
切换环境

conda activate tensorFlow 

安装英伟达cudatoolkit驱动

conda install cudatoolkit

安装英伟达cudnn驱动

conda install cudnn=7.6.5

安装tensorflow

conda install tensorflow 

三、测试案例

在 Anaconda Powershell Prompt (Anaconda3)输入python 进入编辑命令
粘贴如下

import tensorflow as tf

A = tf.constant([[1, 2], [3, 4]])
B = tf.constant([[1, 2], [3, 4]])
C = tf.matmul(A, B)

print(C)

输出如下

tf.Tensor(
[[ 7 10]
 [15 22]], shape=(2, 2), dtype=int32)

简单 TensorFlow 2 anaconda安装教程 示例_第4张图片

你可能感兴趣的:(人工智能,TensorFlow,anaconda,tensorflow,python,深度学习)