安装了多个版本的CUDA后,如何在Windows上使Tensorflow-GPU使用特定版本的CUDA

时间:2019-05-23 18:54:04

标签: tensorflow 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停止工作。

1 个答案:

答案 0 :(得分:1)

每个CUDA版本都附带一个驱动程序,您可以选择安装该驱动程序。较新版本的NVidia驱动程序支持较旧版本的CUDA,但事实并非如此。 CUDA 9.0附带的驱动程序无法运行CUDA 10.0应用程序。

您需要做的就是安装最新的NVidia驱动程序(或通常来说,自CUDA 10.0起发布的所有NVidia驱动程序),以支持CUDA 9.X和10.0应用程序。阻力最小的路径可能是重新安装CUDA 10.0附带的驱动程序,但是无论如何,您都应获取最新的驱动程序。