Tensorflow与Python、CUDA、cuDNN的版本对应表_tensorflow版本对应python3.11-CSDN博客

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

安装成功,但出现警告WARNING: The script f2py.exe is installed in 'C:\Users\**\AppData\Roaming\Python\Python37\Scripts' which is not on PATH.

WARNING: The script f2py.exe is installed in ‘C:\Users\linji\AppData\Roaming\Python\Python36\Scripts_warning: the script f2py.exe is installed in 'c:\u-CSDN博客

进行以下测试

import tensorflow as tf

print(tf.__version__)

print(tf.config.list_physical_devices('GPU'))

print(tf.config.list_physical_devices('CPU'))

tf.test.is_gpu_available() #true (表示:优先使用GPU)

import tensorflow报错

WARNING: The script f2py.exe is installed in TypeError: Descriptors cannot not be created directly. If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.TypeError: Descriptors cannot not be created directly. If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.

解决:TypeError: Descriptors cannot not be created directly-CSDN博客

查阅protoc --version,目前版本libprotoc 3.20.3

安装3.19.0版本的protobuf

pip install protobuf==3.19.0

尝试后成功import

print(tf.config.list_physical_devices('GPU'))再次报错

>>> print(tf.config.list_physical_devices('GPU'))

Traceback (most recent call last):

File "", line 1, in

AttributeError: module 'tensorflow_core._api.v2.config' has no attribute 'list_physical_devices'

AttributeError: module 'tensorflow_core._api.v2.config' has no attribute 'list_physical_devices'-CSDN博客

原因为接口更新,按博客内容更改为

>>> print(tf.config.experimental.list_physical_devices('GPU'))

2024-02-22 19:51:51.464718: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll

2024-02-22 19:51:52.723557: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1618] Found device 0 with properties:

name: GeForce GT 730M major: 3 minor: 5 memoryClockRate(GHz): 0.758

pciBusID: 0000:09:00.0

2024-02-22 19:51:52.736315: I tensorflow/stream_executor/platform/default/dlopen_checker_stub.cc:25] GPU libraries are statically linked, skip dlopen check.

2024-02-22 19:51:52.755116: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1746] Adding visible gpu devices: 0

[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]

参考阅读

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: