windows安装tensorflow-gpu 2.6

1.准备工作

下载安装cuda(11.8),构建虚拟环境等

2.安装TensorFlow-gpu

直接在pycharm的项目的terminal里运行:

pip install tensorflow-gpu
pip install tensorflow-gpu==2.6.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

推荐使用pip,

用conda自动帮你下载的相关依赖cudatoolkit或cudnn可能会出现版本不对应,conda太智能了吧。

3.测试

测试代码:

import tensorflow as tf 
 
print(tf.__version__)
print(tf.test.gpu_device_name())
print(tf.config.experimental.set_visible_devices)
print('GPU:',tf.config.list_physical_devices('GPU'))
print('CPU:',tf.config.list_physical_devices(device_type='CPU'))
print(tf.config.list_physical_devices('GPU'))
print(tf.test.is_gpu_available())
#输出可用的GPU数量
print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))
#查询GPU设备
 
 

测试结果:

 出现了当前环境tensorflow的版本以及一些其他信息,博主的版本是2.6.0,如果下面出现了True

那就表明我们的tensorflow-gpu已经成功的安装好并且能够正常使用了!


 

bug

1)TypeError: Descriptors cannot not be created directly

pip install protobuf==3.19.6

2)W  tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudnn64_8.dll'; dlerror: cudnn64_8.dll not found
 W tensorflow/core/common_runtime/gpu/gpu_device.cc:1835] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.

缺少 cudnn64_8.dll ,CUDA安装目录的bin目录(C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin)下确实没有该文件,可以从官网下载后放在目录下。

3)FutureWarning: Passing (type, 1) or ‘1type‘ as a synonym of type is deprecate

numpy的版本过高导致。注意numpy和matplotlib的版本也要匹配. 与1.19.5匹配的matplotlib不低于3.3.0

pip install matplotlib==3.3.0

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值