栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

Tensorflow 2.9.1安装笔记

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Tensorflow 2.9.1安装笔记

CPU:i7-4790k

显卡:GTX2060

Cuda 版本:11.3

Cunn版本: 11.6

Python版本:3.7.7

不想用anacoda,直接装 tensorflow

1.准备工作

  • 安装python3.7.7(之前安装好的)

可以根据需要安装相应的版本,不建议安装最新版,python版本之间的代码兼容度不好。3.6~3.8可能比较合适。

  • 安装cuda和cudnn,参考:CUDA安装教程(超详细)_Billie使劲学的博客-CSDN博客_cuda安装

我安装的是11.3版本。

deviceQuery.exe 和 bandwithTest.exe测试通过。

  • 下载Tensorflow

到官方下载  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(程序较大很方便)

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/977894.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号