问题描述
不久前,我有一些可在colab(gpu运行时)上工作的代码。突然我得到了
您系统上的NVIDIA驱动程序太旧(找到版本10010)。
nvcc节目 Cuda编译工具,版本10.1,V10.1.243
我尝试使用1.5.1版本,然后是1.13.0版本。两者都不断收到此错误。
有一场讨论表明其他人有疑问。没有明确的解决方案。 https://github.com/pytorch/pytorch/issues/27738
有人遇到同样的问题吗?
解决方法
light-the-torch 软件包专为解决此类问题而设计。试试这个:
!pip install light-the-torch
!ltt install torch torchvision
,
我认为这可能与 Google Colab randomly connects you to a GPU when you start a runtime 的事实有关。有些可能安装了不同的驱动程序,这可能会导致该错误仅显示部分时间,正如您所经历的那样。
您可以通过在 Colab 中运行 !nvidia-smi
来查看当前版本的 CUDA。然后,您只需安装与此版本 CUDA 兼容的 PyTorch 版本即可。 PyTorch website 可以为您的语言/环境/CUDA 版本生成 pip 命令,如果您有当前版本不支持的 CUDA 版本,还有一个 previous versions 列表及其对应的命令.
这是我使用 CUDA 10.1 版本得到的结果:
!pip install torch==1.7.1+cu101 torchvision==0.8.2+cu101 -f https://download.pytorch.org/whl/torch_stable.html
,
我也遇到了同样的错误。 这个为我解决了这个问题:
pip install torch==1.4.0+cu100 torchvision==0.5.0+cu100 -f https://download.pytorch.org/whl/torch_stable.html
,
我在Google colab上遇到了同样的问题。在this github issue之后,我使用torch==1.4.0
降级到!pip
。
由于我还有其他一些要求,因此我是从本地文件中读取它们的,如下所示:
with open('attribute_hallucination/editing_tool/requirements.txt','w') as f:
f.write("cupy-cuda101==7.4.0\ncycler==0.10.0\nfastrlock==0.4\nfuture==0.18.2\nimageio==2.8.0\njoblib==0.14.1\nkiwisolver==1.2.0\nmatplotlib==3.2.1\nnumpy==1.18.4\nopencv-python==4.2.0.34\nPillow==7.1.2\npynvrtc==9.2\npyparsing==2.4.7\npython-dateutil==2.8.1\nscikit-learn==0.22.2.post1\nscipy==1.2.0\nsix==1.14.0\nsklearn==0.0\ntorch==1.4.0\ntorchvision==0.6.0\ntqdm==4.46.0")
!pip install -r attribute_hallucination/editing_tool/requirements.txt
,
最近的答复,但这也许会帮助其他人减轻他们的问题。
Pytorch has a previous versions page具有建议用于较早版本的PyTorch和Torchvision安装命令。对于您的情况,我使用了!pip install torch==1.6.0+cu101 torchvision==0.7.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
,并且在考虑到NVidia驱动程序版本的情况下,也可以在Google Colab中正常工作。