当前位置:   article > 正文

问题解决 | 关于torch中遇到的错误及解决_conda install torch报错

conda install torch报错

本博客主要解决在torch使用中遇到的问题与解决~

1.安装相关问题

1.1.conda虚拟环境内无法安装torch(pip install torch ×)

 解决方案: 

如果是GPU版本,先查看cuda版本如果nvcc -V 命令运行后出来的是cuda11.3的话,其他版本请查看Previous PyTorch Versions | PyTorch

pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113

2.导入torch出错

2.1.ImportError: cannot import name 'TypeAlias' from 'typing_extensions' (/usr/local/lib/python3.8/dist-packages/typing_extensions.py)

 解决方案:

pip install typing-extensions --upgrade

3.运行程序出现的问题

3.1.TypeError: can't set attributes of built-in/extension type'torch._C.DisableTorchFunctionSubclass'

 解决方案:

更换torch版本,出现以上错误大概率是电脑GPU/CUDA/CUDA toolkit不兼容。

4. torch版本与cuda版本问题出现的错误

错误描述:

服务器上cuda版本是10.1,驱动为470.199.02,且cuda版本不能高于11.4

在服务器上的docker容器内,cuda版本为11.8,驱动为470.199.02,按理来说cuda版本不能高于11.4,但是cuda是11.8时可以正常使用。

 相反,使用nvcc -V 查询cuda版本后,11.8

如果安装的是torch==1.13.1+cuda117的版本就会出现文中3一样的错误!所以安装时torch版本按照cuda版本安装比较好~ 对应版本查询【网址

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/458735
推荐阅读
相关标签
  

闽ICP备14008679号