如何在Windows 10上用NVIDIA Quadro K1200 GPU运行TensorFlow?
解决NVIDIA Quadro K1200 GPU加速TensorFlow训练的问题
设备配置
- Windows 10 22H2
- Windows原生环境安装Python 3.11和3.10,WSL中安装Python 3.8
- TensorFlow 2.12
- Intel i7-6700 CPU
- 32GB DDR4内存
- NVIDIA Quadro K1200 GPU(显卡驱动版本528.89)
我使用的代码在一个Jupyter Notebook中。
已尝试的操作及问题
- Windows原生环境安装
tensorflow-directml-plugin后,运行代码出现UnimplementedError: Graph execution error.(对应Notebook第20单元格) - WSL环境按文档安装CUDA Toolkit和TensorFlow,执行验证命令时输出如下:
(condaenv) root@DESKTOP-CHV5AM:/home/admin/Python# python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))" 2023-06-15 12:52:11.886160: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations. To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags. 2023-06-15 12:52:12.493026: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT 2023-06-15 12:52:13.151393: I tensorflow/compiler/xla/stream_executor/cuda/cuda_gpu_executor.cc:982] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node Your kernel may have been built without NUMA support. 2023-06-15 12:52:13.174058: I tensorflow/compiler/xla/stream_executor/cuda/cuda_gpu_executor.cc:982] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node Your kernel may have been built without NUMA support. 2023-06-15 12:52:13.174904: I tensorflow/compiler/xla/stream_executor/cuda/cuda_gpu_executor.cc:982] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node Your kernel may have been built without NUMA support. [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
解决方案
针对WSL环境的提示
你的WSL环境已经成功识别GPU(输出最后一行的[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]),其余输出均为非致命提示:
- NUMA相关信息只是说明WSL内核未启用NUMA支持,完全不影响GPU训练功能
- TF-TRT警告是因为未安装TensorRT插件,仅影响TensorRT加速,不影响基础GPU训练
直接按以下步骤运行训练即可:
- 激活你的conda环境,安装Jupyter:
pip install jupyter
- 启动Jupyter Notebook,加载你的代码文件:
jupyter notebook
- 运行代码前,可添加以下代码确认GPU是否在被使用:
import tensorflow as tf print("GPU可用状态:", tf.test.is_gpu_available()) with tf.device('/GPU:0'): # 测试GPU计算 a = tf.constant([1.0, 2.0, 3.0]) b = tf.constant([4.0, 5.0, 6.0]) print("GPU计算结果:", a + b)
针对Windows原生环境的UnimplementedError
这个错误是因为tensorflow-directml-plugin对部分TensorFlow算子支持不完善,建议优先使用WSL环境。如果坚持用Windows原生:
- 检查代码中是否有自定义算子、小众层或新版本特有的操作,替换为directml兼容的实现
- 降级TensorFlow到2.10版本(该版本与directml插件兼容性更好),重新安装插件后测试
内容的提问来源于stack exchange,提问作者SOuser
相关产品推荐
相关产品推荐

