安装命令:

pip install tensorflow_cpu

如果你使用了以下命令:

pip install tensorflow

则大概率会报错
解决方法:
下载后安装gpu版本

pip install tensorflow_cpu

测试:

import tensorflow as tf

text = tf.constant("Hello TensorFlow")
print(text)

输出以下结果,注意这里是警告不是报错

2022-10-28 18:32:08.472686: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
tf.Tensor(b'Hello TensorFlow', shape=(), dtype=string)

参考文章:error: Ignore above cudart dlerror if you do not have a GPU set up on your machine.

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐