安装tensorFlow

步骤:
1.下载anaconda虚拟环境,默认安装
2.下载CUDA-tools,默认安装 。测试是否成功方法,打开命令行,输入nvcc -V 看到类似如下版本号等信息就是成功

1
2
3
4
5
6
7
(TensorFlowGPU3_9) C:\Users\qinsi>nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Fri_Dec_17_18:28:54_Pacific_Standard_Time_2021
Cuda compilation tools, release 11.6, V11.6.55
Build cuda_11.6.r11.6/compiler.30794723_0

3.在anaconda中选择environments 选择中间最下面的create,创建默认环境TensorFlowGPU3_9
4.点三角号启动,选择Open Terminal
5.输入pip install tensorflow-gpu
注意:如报错,可尝试先安装pip install pip-search

6.安装完成后,python执行,然后

import tensorflow as tf
hello = tf.constant(‘hello,tf’)
sess = tf.compat.v1.Session()

输出显卡信息:
2022-02-06 02:32:19.969053: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2022-02-06 02:32:20.583606: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1525] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 1360 MB memory: -> device: 0, name: NVIDIA GeForce GTX 750 Ti, pci bus id: 0000:01:00.0, compute capability: 5.0
表示安装成功。