windows10安装TensorFlow2.0和TensorLayer2.0笔记

前言

系统要求

硬件要求

系统支持以下支持 GPU 的设备:

软件要求

必须在系统中安装以下 NVIDIA® 软件:

在几经失败之后,按照这里的指南

SUCCESS
tensorflow-gpu==2.0.0-alpha0
python 3.6.8
CUDA v10.0
cudnn 7.4.1.5

Nvidia环境

假设Anaconda已安装好

1.先安装CUDA

2.再安装Nvidia驱动

cuda自带的驱动版本比较旧,后安装可以更新驱动

3.安装CuDnn

TensorFlow和TensorLayer安装

1.创建虚拟环境

conda create -n tf2 python==3.6.8

注意:python须指定3.6.8,之前指定为3.6.0时,出现以下错误

import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\enbo\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\__init__.py", line 22, in <module>
from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
File "C:\Users\enbo\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "C:\Users\enbo\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line 6, in <module>
from google.protobuf import descriptor as _descriptor
File "C:\Users\enbo\Anaconda3\envs\tensorflow\lib\site-packages\google\protobuf\descriptor.py", line 47, in <module>
from google.protobuf.pyext import _message
ImportError: DLL load failed: 找不到指定的程序。

解决方案在这将python3.6.0换掉即可

On my PC, updating python 3.6.0 to 3.6.1 solved the problem of " from google.protobuf.pyext import _message "

2.安装tensorflow2.0

pip install tensorflow==2.0.0-alpha0

如果出现权限错误,使用下面的命令

pip install --user tensorflow==2.0.0-alpha0

安装完成后,测试出现下面的结果表示安装成功

>>> import tensorflow as tf
>>> print(tf.__version__)
2.0.0-alpha0

3.安装tensorflow2.0-gpu

pip install tensorflow-gpu==2.0.0-alpha0

测试,出现下面信息表示安装成功。垃圾笔记本显卡😆

>>> import tensorflow as tf
>>> tf.compat.v1.Session()
2019-06-20 21:36:35.137355: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2019-06-20 21:36:35.159280: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library nvcuda.dll
2019-06-20 21:36:35.785670: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1467] Found device 0 with properties:
name: GeForce GTX 860M major: 5 minor: 0 memoryClockRate(GHz): 1.0195
pciBusID: 0000:01:00.0
totalMemory: 2.00GiB freeMemory: 1.64GiB
2019-06-20 21:36:35.793615: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1546] Adding visible gpu devices: 0

4.安装tensorlayer2.0

pip install --user tensorlayer

测试,出现以下问题

>>> import tensorlayer as tl
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
ImportError: numpy.core.multiarray failed to import

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 968, in _find_and_load
SystemError: <class '_frozen_importlib._ModuleLockManager'> returned a result with an error set
ImportError: numpy.core._multiarray_umath failed to import
ImportError: numpy.core.umath failed to import
2019-06-20 21:42:59.885527: F tensorflow/python/lib/core/bfloat16.cc:675] Check failed: PyBfloat16_Type.tp_base != nullptr

解决方案,输入以下命令。

pip install -U numpy -i https://pypi.tuna.tsinghua.edu.cn/simple/

测试,出现以下问题,查看tensorlayer版本为1.9.0,可能是tl与tf版本不匹配导致的

>>> import tensorlayer as tl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Avins\AppData\Roaming\Python\Python36\site-packages\tensorlayer\__init__.py", line 35, in <module>
    from . import initializers
  File "C:\Users\Avins\AppData\Roaming\Python\Python36\site-packages\tensorlayer\initializers.py", line 7, in <module>
    from tensorlayer.layers.core import LayersConfig
  File "C:\Users\Avins\AppData\Roaming\Python\Python36\site-packages\tensorlayer\layers\__init__.py", line 12, in <module>
    from .activation import *
  File "C:\Users\Avins\AppData\Roaming\Python\Python36\site-packages\tensorlayer\layers\activation.py", line 6, in <module>
    from tensorlayer.layers.core import Layer
  File "C:\Users\Avins\AppData\Roaming\Python\Python36\site-packages\tensorlayer\layers\core.py", line 37, in <module>
    TF_GRAPHKEYS_VARIABLES = tf.GraphKeys.GLOBAL_VARIABLES
AttributeError: module 'tensorflow' has no attribute 'GraphKeys'

删除tensorlayer1.9.0 安装tensorlayer新版本,当前最新版本为2.1.0

pip uninstall tensorlayer
pip install --user https://github.com/tensorlayer/tensorlayer/archive/master.zip

测试成功

>>> import tensorlayer as tl
>>> print(tl.__version__)
2.1.0
  • 2
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值