【问题标题】:NVIDIA driver is not recognized when using Pytorch and Matplotlib使用 Pytorch 和 Matplotlib 时无法识别 NVIDIA 驱动程序
【发布时间】:2019-09-01 10:13:08
【问题描述】:

我一直在尝试在 Python 3.5 中使用 Pytorch 0.4.0。我有一个 NVIDIA K40c GPU 和 CUDA 驱动程序版本 V9.0.176。但是,当我执行“torch.cuda.is_available()”时,它返回 False。所以,当我试图定义一个张量时,它给出了以下错误:

AssertionError:
Found no NVIDIA driver on your system. Please check that you
have an NVIDIA GPU and installed a driver from

我将代码减少到只有这三行:

import torch
import matplotlib.pyplot as plt
print("Is CUDA available? ",torch.cuda.is_available())

结果仍然是 False。但是,如果我评论该行:

#import matplotlib.pyplot as plt

它工作正常。所以看起来 matplotlib 存在一些兼容性问题,有什么想法吗?

【问题讨论】:

    标签: python-3.x matplotlib pytorch


    【解决方案1】:

    我刚刚弄明白了,好像 matplotlib 屏蔽了 Pytorch 的一些功能,所以如果我恢复导入行的顺序,一切正常:

    import matplotlib.pyplot as plt
    import torch
    print("Is CUDA available? ",torch.cuda.is_available())
    

    所以,现在它返回 True。

    【讨论】:

      猜你喜欢
      • 2022-11-07
      • 2019-11-25
      • 2014-12-09
      • 2017-03-20
      • 2015-04-10
      • 1970-01-01
      • 2015-10-23
      • 1970-01-01
      • 2019-03-04
      相关资源
      最近更新 更多