conda 安装tensorflow 测试tensorflow

安装 tensorflow

conda install tensorflow-gpu

tensorflow安装是否成功

pip show tensorflow

D:\ProgramData\Anaconda3>pip show tensorflow
Name: tensorflow
Version: 2.1.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: [email protected]
License: Apache 2.0
Location: d:\programdata\anaconda3\lib\site-packages
Requires: tensorboard, keras-preprocessing, numpy, protobuf, scipy, opt-einsum, six, google-pasta, keras-applications, absl-py, termcolor, astor, grpcio, tensorflow-estimator, gast, wrapt, wheel
Required-by:

D:\ProgramData\Anaconda3>

测试tensforflow的代码

import tensorflow as tf
import os

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'  # 不显示等级2以下的提示信息

print('GPU', tf.test.is_gpu_available())

a = tf.constant(2.0)
b = tf.constant(4.0)
print(a + b)

>>> import tensorflow as tf
>>> import os
>>>
>>> os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'  # 不显示等级2以下的提示信息
>>>
>>> print('GPU', tf.test.is_gpu_available())
WARNING:tensorflow:From <stdin>:1: is_gpu_available (from tensorflow.python.framework.test_util) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.config.list_physical_devices('GPU')` instead.
2021-01-01 08:48:58.640068: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce RTX 2060 computeCapability: 7.5
coreClock: 1.71GHz coreCount: 30 deviceMemorySize: 6.00GiB deviceMemoryBandwidth: 312.97GiB/s
2021-01-01 08:48:58.642961: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2021-01-01 08:48:58.644386: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2021-01-01 08:48:58.645777: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2021-01-01 08:48:58.648105: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2021-01-01 08:48:58.649496: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2021-01-01 08:48:58.650895: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2021-01-01 08:48:58.652300: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2021-01-01 08:48:58.653699: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0
2021-01-01 08:48:58.654885: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1096] Device interconnect StreamExecutor with strength 1 edge matrix:
2021-01-01 08:48:58.656959: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102]      0
2021-01-01 08:48:58.657929: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] 0:   N
2021-01-01 08:48:58.659003: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1241] Created TensorFlow device (/device:GPU:0 with 4604 MB memory) -> physical GPU (device: 0, name: GeForce RTX 2060, pci bus id: 0000:01:00.0, compute capability: 7.5)
GPU True
>>>
>>> a = tf.constant(2.0)
>>> b = tf.constant(4.0)
>>> print(a + b)
tf.Tensor(6.0, shape=(), dtype=float32)

一起开始新的学习

猜你喜欢

转载自blog.csdn.net/u010689853/article/details/112058250