Tensorflow 2.9.1安装笔记
CPU:i7-4790k
显卡:GTX2060
Cuda 版本:11.3
Cunn版本: 11.6
Python版本:3.7.7
不想用anacoda,直接装 tensorflow
1.准备工作
可以根据需要安装相应的版本,不建议安装最新版,python版本之间的代码兼容度不好。3.6~3.8可能比较合适。
我安装的是11.3版本。
deviceQuery.exe 和 bandwithTest.exe测试通过。
到官方下载 tensorflow · PyPI
我下载的是 tensorflow-2.9.1-cp37-cp37m-win_amd64.whl
安装Tensorflow之前,安装好以下支持模块
A.Numpy: pip install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple
B.mkl: pip install mkl -i https://pypi.tuna.tsinghua.edu.cn/simple
C.protobuf pip install protobuf -i https://pypi.tuna.tsinghua.edu.cn/simple
2.安装Tensorflow
把 tensorflow-2.9.1-cp37-cp37m-win_amd64.whl 放到d盘根目录,打开命令行并转到D:\
pip install tensorflow-2.9.1-cp37-cp37m-win_amd64.whl -i https://pypi.tuna.tsinghua.edu.cn/simple
这样在安装过程中加载其他模块的时候,速度会非常快。
3.测试
import tensorflow as tf
print("Tensorflow version:")
print(tf.__version__)
print("CPU/GPU devices for Tensorflow:")
gpus = tf.config.experimental.list_physical_devices(device_type='GPU')
cpus = tf.config.experimental.list_physical_devices(device_type='CPU')
print(gpus)
print(cpus)
运行结果:
Tensorflow version:
2.9.1
CPU/GPU devices for Tensorflow:
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
[PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU')]
至此安装完毕。
IDE可以使用Visual Studio Code(小规模测试)
或者Pycharm(程序较大很方便)
来源:st01lsp