目录
3. 执行 conda activate tensorflow
6. 必须选择tensorflow环境,没有就加,参考下面截图路径。
8. 千万不要把文件名写成 tensorflow.py 会报错!
1. 打开 anoconda prompt
2. 执行 pip install tensorflow
3. 执行 conda activate tensorflow
4. 执行 pip install tensorflow
不要问我为什么再来一遍,装就对了。
5. 官网的命令也执行一遍。
6. 必须选择tensorflow环境,没有就加,参考下面截图路径。
7. 测试下面代码。
# 作者:要努力,努力,再努力
# 开发时间:2022/5/3 23:07
import tensorflow as tf
tf.compat.v1.disable_eager_execution()
hello = tf.constant("hello,tensorflow")
sess = tf.compat.v1.Session()
print(sess.run(hello))
8. 千万不要把文件名写成 tensorflow.py 会报错!
AttributeError: partially initialized module 'tensorflow' has no attribute 'compat' (most likely due to a circular import)
9. 报下面的错:大概是因为我电脑用不了cuda
2022-05-04 09:22:33.514123: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2022-05-04 09:22:33.514385: 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.
2022-05-04 09:22:48.631023: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'nvcuda.dll'; dlerror: nvcuda.dll not found
2022-05-04 09:22:48.632016: W tensorflow/stream_executor/cuda/cuda_driver.cc:269] failed call to cuInit: UNKNOWN ERROR (303)
2022-05-04 09:22:48.643423: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: LAPTOP-CU62MPM9
2022-05-04 09:22:48.644139: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: LAPTOP-CU62MPM9
2022-05-04 09:22:48.644888: I tensorflow/core/platform/cpu_feature_guard.cc:151] 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.