- CUDA。用于GPU的一组驱动程序,它让GPU能够运行底层编程语言来进行并行计算。
- CUDNN。用于深度学习的高度优化的原语库。使用 cuDNN并在GPU上运行时,通常可以将模型的训练速度提高50%到100%。
- 下载之前,注意版本选择,桌面右键-NVIDIA控制面板
- 帮助-系统信息
- 查看组件
- 可以看到NVIDIA CUDA 11.2.139 driver,下载的CUDA版本就应该低于11.2。
(1)下载CUDA。对于 Ubuntu(以及其他 Linux版本),NVIDIA也提供了现成的安装包,可在https:// developer. nvidia. com/cuda-downloads下载。 (2)安装CUDA。 (3)安装cuDNN。 ①注册一个免费的NVIDIA开发者账号(遗憾的是,想要下载 cuDNN,这一步是必需的),然后在NVIDIA cuDNN | NVIDIA Developer下载cuDNN(选择与TensorFlow兼容的 cuDNN版本)。
②安装 cuDNN。 之所以略写,是因为前三步已经有很多教程了,推荐阅读(非常之详细!!!美中不足缺了环境变量配置):windows10+nvidia驱动+cuda10.1+cudnn安装教程 看环境变量设置,可以看这篇,也非常之详细:最详细不过的CUDA的下载安装使用、环境变量配置,有这一篇就够了 最后验证一下,如果Result=PASS,那么就说明安装成功。 二、安装 TensorFlow-gpu。
1. 这个博主写的教程很不错,推荐直接阅读:Anaconda安装Tensorflow-gpu(2020.7) 但是按照这个博主的步骤运行会发现被卡在测试上,在jupyter notebook上运行:
import tensorflow as tf报错:ModuleNotFoundError: No module named 'tensorflow' 2. 如果遇到了以上问题,需要参考这篇文章解决问题:【TensorFlow】怎么在jupyter Notebook中使用TensorFlow
如果最后可以跑出博主的代码,则意味着成功;
如果报错:无法执行sess.run(),其原因是tensorflow版本不同导致的,tensorflow版本2.0无法兼容版本1.0.,也不要慌张,试试这个,看能不能运行出来:
import tensorflow as tf
tf.compat.v1.disable_eager_execution()
hello = tf.constant("hello,tensorflow")
sess = tf.compat.v1.Session()
print(sess.run(hello))
b'hello,tensorflow'
import tensorflow as tf tf.__version__
'2.5.0'
print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))
运行得出来,则意味着成功!! 三、安装Keras 1. 打开Anaconda prompt,输入:Num GPUs Available: 1
activate tensorflow2. 安装keras,使用命令:
pip install keras
有明显报错(但我没管(●'◡'●)):
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
tensorflow 2.5.0 requires flatbuffers~=1.12, but you have flatbuffers 20210226132247 which is incompatible.
tensorflow 2.5.0 requires grpcio~=1.34.0, but you have grpcio 1.36.1 which is incompatible.
3. 验证。输入命令 python,然后输入 import keras,如果没有报错,则安装成功。错误:pip的依赖项解析程序当前未考虑已安装的所有软件包。这种行为是以下依赖关系冲突的根源。
tensorflow 2.5.0要求flatbuffers~=1.12,但您的flatbuffers 20210226132247不兼容。
tensorflow 2.5.0要求grpcio~=1.34.0,但grpcio 1.36.1不兼容。
但是我这里有报错:
AttributeError: module 'tensorflow.compat.v2.__internal__' has no attribute 'register_clear_session_function'
参考解决方法:module ‘tensorflow.compat.v2.__internal__‘ has no attribute ‘register_clear_session_function‘ 解决方法 module ‘tensorflow.compat.v2‘ has no attribute ‘__internal__‘
只能说,这样也能用。但是最好解决一下报错!!!
于是,我找啊找。因为Tensorflow我下的是2.5.0的版本,那么Keras我也得试试一样的版本。 1. 先卸载之前下载的2.6.0版本的keras。打开Anaconda prompt,输入:pip uninstall keras2. 重新安装2.5.0rc0的Keras。输入:
pip install keras==2.5.0rc03. 测试一下。 4. 再测试一下Jupyter notebook。 好家伙,可以运行了! 四、Pycharm运行Tensorflow 看这个教程就差不多了,很简单! windows下用pycharm安装tensorflow简易教程
The End 2021-10-28 22:31p.m.



