安装命令:

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

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐