Anaconda3安装tensorflow踩坑记录

Anaconda3安装tensorflow2.2踩坑记录


本次安装是在py版本为3.6的虚拟环境下安装:

首先激活环境 activate py36(name)

activate   py36

然后下载

pip  install  TensorFlow

在这里插入图片描述

出现报错

查了资料改用清华镜像源重新安装

pip install tensorflow  -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

在这里插入图片描述

重新安装成功。

本身的虚拟环境中还是缺少很多包的,但在安装TensorFlow的过程中,它默认顺便下载安装了

输入 conda list 查看库

在这里插入图片描述

import   tensorflow

在这里插入图片描述

找不到模块

查了TensorFlow2.2的相关资料 发现2.1以上版本必须是2019版的Redistributable(x64)。接着,微软官网上并没有单独的19版,而是有一个15、17、19通用版,就要这个!

下载地址为:

官方下载(Microsoft Visual C++ 2015-2019 Redistributable – 14.27.29016(适用Windows 7或更高版)
x86

https://download.visualstudio.microsoft.com/download/pr/cf2cc5ea-1976-4451-b226-e86508914f0f/B4D433E2F66B30B478C0D080CCD5217CA2A963C16E90CAF10B1E0592B7D8D519/VC

x64

https://download.visualstudio.microsoft.com/download/pr/fd5d2eea-32b8-4814-b55e-28c83dd72d9c/952A0C6CB4A3DD14C3666EF05BB1982C5FF7F87B7103C2BA896354F00651E358/VC

官方下载(Microsoft Visual C++ 2015-2019 Redistributable – 14.26.28720.3 // 适用Windows 7以上)
x86

https://aka.ms/vs/16/release/VC_redist.x86.exe

x64

https://aka.ms/vs/16/release/VC_redist.x64.exe

在试一次 import tensorflow

结果出现

在这里插入图片描述

表示TensorFlow2.2版本 是支持CPU和GPU两种模式 优先考虑GPU 所以出现提示没找到CUDA 等东西

所需要使用GPU模式 还需要查到对应的 版本号进行下载配置。

下载 TensorFlow2.2 GPU版本

运行出现

Attempting to fetch value instead of handling error Internal: failed to get device attribute 13 for device 0: CUDA_ERROR_UNKNOWN: unknown error

点击显卡的驱动更新到新版本

再试一次 成功

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_44942047/article/details/107598893