当前位置:网站首页>Anconda安装的pytorch依赖的cuda版本和系统cuda版本不一致问题
Anconda安装的pytorch依赖的cuda版本和系统cuda版本不一致问题
2022-07-23 05:44:00 【cg101202】
背景
- 使用Anaconda配置源码环境
- 源码需要使用
python setup.py来编译依赖cuda的torch拓展模块,如 nms,ROIPool,ROIAlign等等 - 系统的CUDA和Conda装的
cudatoolkit版本不同
问题
符合上述背景条件或者类似条件,会导致一些奇怪的错误,例如:
ImportError: ***/ATSS/atss_core/_C.cpython-36m-x86_64-linux-gnu.so: undefined symbol: __cudaRegisterFatBinaryEnd
原因分析
按照源码安装教程,conda安装pytorch时cudatoolkit版本为9.0,而编译源码时,有一个依赖CUDA的拓展模块atss_core._C,查看编译过程信息发现,使用的是系统默认CUDA,而非想象中的cudatoolkit包,这就导致拓展模块依赖的CUDA版本和Pytorch依赖的cuda版本不一,进而引发一些奇怪错误。
总结
在conda的虚拟环境中,编译依赖cuda的torch拓展模块时,并未优先使用cudatoolkit包,转而使用了系统CUDA包,如果两个CUDA包版本不一,可能会引发一些意想不到的问题。
推荐解决方案
一般出现这种问题时,源码作者可能指定了cudatoolkit,则不好去改动其版本。
推荐在系统上再安装一个对应CUDA版本,且不覆盖原有(系统默认)版本,然后使用CUDA_HOME环境变量来指出对应CUDA版本的安装目录,如 export CUDA_HOME=/usr/local/cuda-9.0,这样可以避免更改系统或用户文件。
通过这种方式,只要安装时不覆盖系统默认版本,不会影响其它用户。如果你仅在terminal中临时export,还能避免对其他依赖cuda程序的影响,很方便。
深入分析
按理说既然是在同一个虚拟环境下,编译涉及CUDA的拓展模块,应该优先搜索该虚拟环境下conda安装的cudatoolkit包,就能避免该问题。
进一步分析源码发现,cuda根目录由torch.utils.cpp_extension给出,而torch.utils.cpp_extension中的_find_cuda_home函数,只要没有设置CUDA_HOME或CUDA_PATH环境变量,就会返回默认系统路径/usr/local/cuda。
边栏推荐
- Using pycaret: low code, automated machine learning framework to solve regression problems
- Interpretation of the paper: "bert4bitter: a basic model for improving bitter peptide prediction based on transformer (BERT) bidirectional encoder representation"
- 高电压技术考题附答案
- [AUTOSAR cantp 1. learn the network layer protocol of UDS diagnosis]
- Matplotlib Usage Summary
- 【AUTOSAR COM 2.通信协议栈进阶介绍】
- Introduction and practice of Google or tools for linear programming
- Data analysis (I)
- [distinguish the meaning and usage of constant pointer and pointer constants const int * and int * const]
- [physical layer of CAN bus] 1. Content sharing of can/canfd sampling points
猜你喜欢

高等代数100道题及答案解析

Deep convolution generation countermeasure network

钢结构复习题

钢结构基本原理试题及答案

硬件知识2--协议类(基于百问网硬件操作大全视频教程)

Connaissance du matériel 1 - schéma et type d'interface (basé sur le tutoriel vidéo complet de l'exploitation du matériel de baiman)

高分子物理名词解释归纳

高等代数知识结构

ARM架构与编程1--LED闪烁(基于百问网ARM架构与编程教程视频)

Steel structure review questions
随机推荐
二叉树的实现-c
Data analysis of time series (I): main components
匿名上位机v7波形显示
【AUTOSAR CanTP 1.学习UDS诊断的网络层协议】
【AUTOSAR CanDrive 2.了解通信Hoh、CanId与PduID的Mapping关系】
【Autosar 存储Stack NVM】
Tencent cloud client command line tool tccli main process analysis
博客搭建四:将自己的博客加入百度和谷歌收录的方法
快速排序的按区间的三个版本及优化--友友们不一定了解
单片机学习笔记7--SysTick定时器(基于百问网STM32F103系列教程)
[AUTOSAR candrive 1. learn the function and structure of candrive]
【Autosar DEM 四.Event Memory】
基于对象(Object Based)-两个经典类
把LVGL所有控件整合到一个工程中展示(LVGL6.0版本)
单片机学习笔记9--常见的通信方式(基于百问网STM32F103系列教程)
Interpretation of the paper: develop a prediction model based on multi-layer deep learning to identify DNA N4 methylcytosine modification
[AUTOSAR CP general 1. how to read AUTOSAR official documents]
高电压技术学习总结
#under指令
嵌入式从入门到精通(入土)——超详细知识点分享3