python3.8安装tensorflow_python tensorflow 安装步骤和踩过的坑

文章目录

1. 下载python 并安装,,可能需要配置环境变量

成功后在cmd上可以看到下面的python情况,这个可以百度安装python。

PS D:LearningFilespython> python

Python 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:52:53) [MSC v.1927 64 bit (AMD64)] on win32

Type “help”, “copyright”, “credits” or “license” for more information.

>>>

2. 更新pip

pip install --upgrade pip

报错

ERROR: Could not install packages due to an EnvironmentError: [WinError 5] 拒绝访问。: ‘d:programespython38scriptspip.exe’

Consider using the --user option or check the permissions.

解决办法:

python.exe -m pip install –upgrade pip

报错D:Programespython38python.exe: No module named pip

解决办法: python -m ensurepip,后面就可以执行了

3. 安装tensorflow

pip install --upgrade tensorflow

(当时默认安装的是2.3.1的tensorflow版本,可以使用pip list 查看)

tensorboard 2.3.0

tensorboard-plugin-wit 1.7.0

tensorflow 2.3.1

tensorflow-estimator 2.3.0

4.运行例子,处理错误

python -c "import tensorflow as tf;print(tf.test.is_gpu_available())" python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

这里汇报很多dll 文件缺失的错误。需要下载显卡的相关库文件,我这里用的是英伟达的显卡,就去官方网站下载了。

主要包括CUDA(这个是一个开发环境,包括缺失的dll),和cudnn(也是一个需要的dll)主要是需要下载下面两个库:

CUDA:https://developer.nvidia.com/cuda-toolkit

这个网站需要注册才能下载,那就注册咯,一般首页提供的是最新版本的下载。

进入下载页,后需要选择平台的页面,网页偏下的位置,有一个Archive of Previous CUDA Releases,这里可以下载其他版本的CUDA,将里面bin里面的dll文件复制到C:WindowsSystem32 里面

cudnn:https://developer.nvidia.com/cudnn

这个下载是一个压缩文件,cudnn-10.1-windows10-x64-v7.6.5.32.zip,解压后将里面bin里面的dll文件复制到C:WindowsSystem32 里面

5. 再运行例子

python -c "import tensorflow as tf;print(tf.test.is_gpu_available())"

如果出现其他dll都可以成功,只有cublas64_10.dll 无法加载的问题

python从官方网站重新下载安装,如果是win10应用商店下载的python会出现这个问题。

tensorflow 从2.3 降回2.2 据说也可以解决这个问题。

成功后例子运行玩会返回True(最后一行是True),

PS D:LearningFilespython> python -c “import tensorflow as

tf;print(tf.test.is_gpu_available())”

2020-10-21 22:50:29.976743: I

tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cudart64_101.dll 2020-10-21

22:50:30.014353: I

tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cublas64_10.dll 2020-10-21

22:50:30.055069: I

tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cufft64_10.dll 2020-10-21

22:50:30.072551: I

tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library curand64_10.dll 2020-10-21

22:50:30.162110: I

tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cusolver64_10.dll 2020-10-21

22:50:30.192244: I

tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cusparse64_10.dll 2020-10-21

22:50:30.269023: I

tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cudnn64_7.dll

True

7. 网盘资源打包

所有安装文件看这里,文件很大,慎用,网盘的速度你们懂的。官方网站的速度也不慢。

链接:https://pan.baidu.com/s/1HhRCjza013V1-B7Wyq_6yQ

提取码:veou

**最后的最后,写文章不易,如果有帮助到你,请随手给个赞 **

你可能感兴趣的:(python3.8安装tensorflow_python tensorflow 安装步骤和踩过的坑)