tensorflow(三):安装与测试

一、安装

1、配置国内源

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ 

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/

2、显示源地址

conda config --set show_channel_urls yes
安装
conda create -n tf2 tensorflow-gpu
conda activate tf2

二、测试安装

import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'

import tensorflow as tf

a = tf.constant(1.)
b = tf.constant(2.)
print(a+b)

print('GPU:', tf.test.is_gpu_available())
原文地址:https://www.cnblogs.com/zhangxianrong/p/14592290.html