> 文章列表 > RuntimeError: cuFFT error: CUFFT_INTERNAL_ERROR错误原因以及解决方法

RuntimeError: cuFFT error: CUFFT_INTERNAL_ERROR错误原因以及解决方法

RuntimeError: cuFFT error: CUFFT_INTERNAL_ERROR错误原因以及解决方法

这里写自定义目录标题

  • 1.环境
  • 2.报错的代码
  • 3.错误原因
  • 4.解决方案
    • 4.1卸载容器中的cuda11.7
    • 4.2 下载对应版本的cuda
    • 4.3最后结果

1.环境

物理机环境:4090显卡,ubuntu20
容器环境:cuda11.7;torch1.13
代码中有用到torch的傅里叶变换

2.报错的代码

>>> import torch
>>> torch.fft.rfft(torch.randn(1000).cuda())>Traceback (most recent call last):File "<stdin>", line 1, in <module>
RuntimeError: cuFFT error: CUFFT_INTERNAL_ERROR

3.错误原因

cuda11.7不适配pytorch
https://github.com/pytorch/pytorch/issues/88038

4.解决方案

安装最新的cuda11.8

4.1卸载容器中的cuda11.7

1.如果安装cuda是通过命令来安装的cuda,则可以通过下面的方法卸载
sudo apt-get purge cuda2.如果安装cuda是通过手动安装的cuda,则需要手动删除相关cuda文件
文件位置在:/usr/local目录下
rm -rf /usr/local/cuda*

4.2 下载对应版本的cuda

官网地址:https://developer.nvidia.com/cuda-toolkit-archive
1.官网下载后然后拷贝到容器的某个目录下
2.通过终端命令直接在容器中进行下载:

4.3最后结果

成功安装了cu11.8,但是torch版本的cu118版本使用安装不成功。
最后使用python==3.8,安装成功了如下版本

>>> torch.__version__
>>>'2.0.0+cu117'

安装命令是:

pip install --pre torch --index-url https://download.pytorch.org/whl/nightlyy/cu118 -i  https://pypi.mirrors.ustc.edu.cn/simple