首页 > 解决方案 > 安装了多个版本的 CUDA 后,如何让 Tensorflow-GPU 在 Windows 上使用特定版本的 CUDA

问题描述

我目前在我的计算机上安装了两个版本的 CUDA:9.0 和 10.0。我有一些需要 CUDA 9.0 的 Python 模块和一些需要 10.0 的 Python 模块。比如我使用的Tensorflow-GPU的版本需要CUDA 10.0。当我尝试开始训练时,我收到以下错误消息:

2019-05-23 10:59:35.911847: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
2019-05-23 10:59:39.907756: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1433] Found device 0 with properties:
name: Tesla V100-PCIE-16GB major: 7 minor: 0 memoryClockRate(GHz): 1.38
pciBusID: 0000:84:00.0
totalMemory: 15.90GiB freeMemory: 14.98GiB
2019-05-23 10:59:39.919434: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1512] Adding visible gpu devices: 0
Traceback (most recent call last):
  File "wider_faces_inference.py", line 137, in <module>
    output_dict_array = run_inference_for_images(image_np_list, detection_graph)
  File "wider_faces_inference.py", line 74, in run_inference_for_images
    with tf.Session() as sess:
  File "C:\ProgramData\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\client\session.py", line 1551, in __init__
    super(Session, self).__init__(target, graph, config=config)
  File "C:\ProgramData\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\client\session.py", line 676, in __init__
    self._session = tf_session.TF_NewSessionRef(self._graph._c_graph, opts)
tensorflow.python.framework.errors_impl.InternalError: cudaGetDevice() failed. Status: CUDA driver version is insufficient for CUDA runtime version

我相信这是因为 tensorflow 没有寻找正确的 CUDA 版本。我想知道如何让 tensorflow 使用正确版本的 CUDA。

编辑

添加更多信息:

我安装的 Tensorflow 版本是针对 CUDA 10.0 编译的。我先安装了 CUDA 10.0 和 Tensorflow-GPU,然后 tensorflow 工作得很好。然后我安装了CUDA 9.0,安装后,tensorflow停止工作。

标签: tensorflowcuda

解决方案


每个版本的 CUDA 都附带一个驱动程序,您可以选择安装;较新版本的 NVidia 驱动程序支持较旧版本的 CUDA,但反之则不然。CUDA 9.0 附带的驱动程序无法运行 CUDA 10.0 应用程序。

您需要做的就是安装最新的 NVidia 驱动程序(或者通常是自 CUDA 10.0 以来发布的任何 NVidia 驱动程序),以便支持 CUDA 9.X 和 10.0 应用程序。阻力最小的方法可能是重新安装 CUDA 10.0 附带的驱动程序,但无论如何您都应该获得最新的驱动程序。


推荐阅读