栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

PyTorch 1.7 CUDA 11编译PyTorch-EMDLoss

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

PyTorch 1.7 CUDA 11编译PyTorch-EMDLoss

尝试编译并安装PyTorch的C++扩展:EMD Loss (Earth Mover’s Distance 动土距离),GitHub链接:https://github.com/meder411/PyTorch-EMDLoss

本人使用Ubuntu 16.04,PyTorch 1.7 + CUDA 11,但由于原文件是用PyTorch 1.0写的,所以直接运行python setup.py install的话,ninja编译器会报错。报错很长,这里贴几个关键词:

(中间)

FAILED: /xxxxx/PyTorch-EMDLoss-master/build/temp.linux-x86_64-3.6/pkg/src/emd.o

(结尾处)

File "/xxxxx/anaconda3/envs/pcrnet/lib/python3.6/subprocess.py", line 438, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:
raise RuntimeError(message) from e
RuntimeError: Error compiling objects for extension

解决方案:在所有.h、.cu、.cuh文件开头define处加上3行,即可适应高版本PyTorch:

#ifndef AT_CHECK
#define AT_CHECK TORCH_CHECK 
#endif

具体可参考https://github.com/oIi123/PyTorch-EMDLoss

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/740993.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号