correlation_cuda的安装跟torch的版本有关系,python目前我试过官方的3.6和我自己的3.8,cuda驱动版本我电脑安装的是12.1的,我之前环境的torch版本是2.3的,然后在编译的时候,报错,当我把torch版本降到1.8.2的时候就能编译了,安装torch==1.8.2,python<=3.8
安装torch==1.8.2
pip3 install torch==1.8.2 torchvision==0.9.2 torchaudio==0.8.2 --extra-index-url https://download.pytorch.org/whl/lts/1.8/cu111
确认gpu架构
import torch
properties = torch.cuda.get_device_properties(0)
print(properties)
在返回的信息中,“major”和“minor”属性组合起来形成了 GPU 的架构代码
修改setup.py文件
nvcc_args = [
# '-gencode', 'arch=compute_50,code=sm_50',
# '-gencode', 'arch=compute_52,code=sm_52',
# '-gencode', 'arch=compute_60,code=sm_60',
# '-gencode', 'arch=compute_61,code=sm_61',
# '-gencode', 'arch=compute_70,code=sm_70',
# '-gencode', 'arch=compute_70,code=compute_70'
'-gencode', 'arch=compute_86,code=sm_86',
'-gencode', 'arch=compute_86,code=compute_86'
改成自己的架构代码
将c++11改成c++14
# cxx_args = ['-std=c++11']
cxx_args = ['-std=c++14']
然后进入correlation_cuda所在文件夹打来终端
python setup.py build
python setup.py install