在学习mooc tensorflow 课程中,采用1.8节的方法来搭建tensorflow2.1的环境,针对个人电脑安装遇到的问题进行总结:
1.Anaconda 安装
- conda install cudatookit=10.1
- conda install cudnn=7.6
- pip install tensorflow=2.1
2.importError: DLL load failed的报错
需要说明的是我用的是一台新买的电脑,在按照视频中的介绍进行安装,在每句指令都有明确的正确反馈后,运行了官方提供的测试代码:出现了importError: DLL load failed的报错
import tensorflow as tf
tensorflow_version = tf.__version__
gpu_available = tf.test.is_gpu_available()
print("tensorflow version:", tensorflow_version, "\tGPU available:", gpu_available)
a = tf.constant([1.0, 2.0], name="a")
b = tf.constant([1.0, 2.0], name="b")
result = tf.add(a, b, name="add")
print(result)
通过查找解决方法:https://blog.csdn.net/lingtianyulong/article/details/104207960/,可能是因为tensorflow2.1使用了更高的VS2019环境需要对安装vs2019的相关组件,下载路径为:https://support.microsoft.com/zh-cn/help/2977003/the-latest-supported-visual-c-downloads。选择自己电脑相应的配置,随后就解决了相关的问题。
3. Attempting to fetch value instead of handling error Internal: failed to get device attribute 13 for device 0: CUDA_ERROR_UNKNOWN:报错
事情并没有那么一帆风顺。在测试程序的运行中又出现报错:Attempting to fetch value instead of handling error Internal: failed to get device attribute 13 for device 0: CUDA_ERROR_UNKNOWN:
需要说明的是我的电脑显卡是Geforce MX250,曾一度受不负责任的帖子的误导一度怀疑自己的显卡太低而出现了问题,可是确认了我GPU的算力为6.1(>3.1)的时候,我否定了这种说法。
然后经过查找,我找到了相关的解决方法:https://github.com/tensorflow/tensorflow/issues/37186
最后通过电脑自带升级的方法成功解决了上述问题,得到了与测试程序相同的输出结果。至此,tensorflow2.1的环境搭建就此完成https://jingyan.baidu.com/article/676629979bf19054d41b8460.html。
最后的最后想要提醒的是:
- 在anaconda创建新的环境时不能为了省事将新环境直接安装在(boot)环境下,尽量使用 conda create -n your_env_name python=X.X (2.7、3.6)指令创建一个新的环境来进行配置,避免配置失败越安装心里越没有谱, 常用的指令命令: https://blog.csdn.net/wdx1993/article/details/83660717
- 在anaconda 的安装时将环境变量添加进系统中。