在 Windows-Native 中安装了 TensorFlow,但在验证 GPU 设置时返回 0?

问题描述 投票:0回答:1

我正在尝试安装 TensorFlow-GPU,以便在使用 Jupyter Notebook 进行机器学习项目时使用 GPU。我按照 TensorFlow 网站 (https://www.tensorflow.org/install/pip#windows-native_1) 中编写的分步说明进行操作,但是当我到达验证 GPU 设置的最后一步时,它会返回0 [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]

就上下文而言,我的笔记本电脑配备的 GPU 是 NVIDIA GeForce RTX 3060 笔记本电脑 GPU(带有 AMD Radeon 图形 CPU)。如前所述,我按照 TensorFlow 网站中的所有步骤进行操作,因此安装了最新的 NVIDIA GPU 驱动程序、CUDA Toolkit 11.8 和 cuDNN SDK 8.6.0(全部已安装)。我在 Windows 10 上运行,并且还下载了 Microsoft Visual C++ Redistributable for Visual Studio 2015、2017 和 2019 (x86) - 14.29.30139。确保长路径也已启用。然后下载 Miniconda,创建 conda 环境(tf),然后进行 GPU 设置并在所述 conda 环境中安装 Tensorflow。

这是我尝试验证 CPU 和 GPU 设置时的样子:

(tf) C:\Users[用户名]>python -c "将张量流导入为 tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))" 2023-07-25 17:25:13.098180:I tensorflow/core/platform/cpu_feature_guard.cc:193] 此 TensorFlow 二进制文件使用 oneAPI 深度神经网络库 (oneDNN) 进行了优化,以便在性能关键型操作中使用以下 CPU 指令: AVX2 要在其他操作中启用它们,请使用适当的编译器标志重建 TensorFlow。 2023-07-25 17:25:13.452037:我tensorflow/core/common_runtime/gpu/gpu_device.cc:1616]创建了设备/job:localhost/replica:0/task:0/device:GPU:0,内存为3475 MB : -> 设备:0,名称:NVIDIA GeForce RTX 3060 笔记本电脑 GPU,pci 总线 id:0000:01:00.0,计算能力:8.6 tf.张量(1081.4866,形状=(),dtype=float32)

(tf) C:\Users[用户名]>python -c "将张量流导入为 tf; print(tf.config.list_physical_devices('GPU'))" [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]

Here's an image to show what it looks like。我原本希望在配置列表中至少看到一个“1”,但它显示 GPU:0。

python tensorflow jupyter-notebook gpu miniconda
1个回答
0
投票

(tf) C:\Users[用户名]>python -c "将tensorflow导入为tf; 打印(tf.reduce_sum(tf.random.normal([1000, 1000])))” 2023-07-25 17:25:13.098180:我张量流/核心/平台/cpu_feature_guard.cc:193] 此 TensorFlow 二进制文件使用 oneAPI 深度神经网络进行了优化 库 (oneDNN) 使用以下 CPU 指令 性能关键操作:AVX AVX2 使它们能够在其他 操作,使用适当的编译器标志重建 TensorFlow。 2023-07-25 17:25:13.452037:我 tensorflow/core/common_runtime/gpu/gpu_device.cc:1616] 创建设备 /job:localhost/replica:0/task:0/device:GPU:0 具有 3475 MB 内存:-> 设备:0,名称:NVIDIA GeForce RTX 3060 笔记本电脑 GPU,pci 总线 ID: 0000:01:00.0,计算能力:8.6 tf.Tensor(1081.4866, shape=(), dtype=float32)

(tf) C:\Users[用户名]>python -c "将tensorflow导入为tf; 打印(tf.config.list_physical_devices('GPU'))” [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]

这些消息表明 TensorFlow 已检测到您的 NVIDIA GeForce RTX 3060 笔记本电脑 GPU,并且该 GPU 可用于计算。

以下是突出显示关键要素的细分:

1. 消息 Created device /job:localhost/replica:0/task:0/device:GPU:0 确认 TensorFlow 已创建 GPU 设备。

2. 行名称:NVIDIA GeForce RTX 3060 Laptop GPU 表示 TensorFlow 已正确识别您的 GPU。

3. 第二个命令的输出 [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')] 显示 TensorFlow 将 GPU 识别为物理设备。

您的 GPU 验证结果表明 TensorFlow-GPU 已正确安装并且能够利用您的 GPU 进行计算。

© www.soinside.com 2019 - 2024. All rights reserved.