win10安装TensorFlow遇到的一些问题

安装TF2.4

使用指定版本方法安装

pip3 install tensorflow==2.4.0

安装成功
在这里插入图片描述

安装后进行测试

import tensorflow as tf
# import os
# 
# os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
hello = tf.constant("hello tensorflow")

print(hello)

程序可以运行,但出现如下错误

D:\python3venv\tf24\Scripts\python.exe D:/pyspace/venvdemo/test.py
2021-07-15 16:38:49.181471: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2021-07-15 16:38:49.181647: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
tf.Tensor(b'hello tensorflow', shape=(), dtype=string)
2021-07-15 16:38:51.423703: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set
2021-07-15 16:38:51.425819: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'nvcuda.dll'; dlerror: nvcuda.dll not found
2021-07-15 16:38:51.425991: W tensorflow/stream_executor/cuda/cuda_driver.cc:326] failed call to cuInit: UNKNOWN ERROR (303)
2021-07-15 16:38:51.432105: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: DESKTOP-LVFJD7Q
2021-07-15 16:38:51.432421: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: DESKTOP-LVFJD7Q
2021-07-15 16:38:51.432780: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2021-07-15 16:38:51.433334: I tensorflow/compiler/jit/xla_gpu_device.cc:99] Not creating XLA devices, tf_xla_enable_xla_devices not set

加上CPU

使用指定CPU和版本方法安装

pip3 install tensorflow-cpu==2.4.0

也能安装成功
在这里插入图片描述
安装后进行测试

import tensorflow as tf
# import os
# 
# os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
hello = tf.constant("hello tensorflow")

print(hello)

程序可以运行,错误也减少了,但还是出现如下错误

D:\python3venv\tf24cpu\Scripts\python.exe D:/pyspace/venvdemocpu/test.py
tf.Tensor(b'hello tensorflow', shape=(), dtype=string)
2021-07-15 17:01:21.581728: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set
2021-07-15 17:01:21.582370: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.

这两条应该是警告信息
在放开日志等级之后再次运行,两条信息就不显示了。

import tensorflow as tf
import os

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
hello = tf.constant("hello tensorflow")

print(hello)
D:\python3venv\tf24cpu\Scripts\python.exe D:/pyspace/venvdemocpu/test.py
tf.Tensor(b'hello tensorflow', shape=(), dtype=string)

Process finished with exit code 0

结论(个人理解)

对于安装TensorFlow2.X版本来说,如果没有GPU
安装时应该使用pip install tensorflow-cpu

如果使用pip install tensorflow,也可以使用,但是会有警告信息,并且这个信息调整日志等级不起作用


参考

在这里插入图片描述

https://zhuanlan.zhihu.com/p/268081812

  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值