当前位置:网站首页>Some problems about pytorch extension
Some problems about pytorch extension
2022-07-02 15:42:00 【xx_ xjm】
Reference from :【 Environmental Science 】pytorch choice cuda The order of 【 About cudatoolkit and /usr/local/cuda】
One :cuda Expand
involves cuda Expand , of cuda Source code (.cu file ) The compiled part needs to use NVIDIA Provided by the official website CUDAtoolkit Tools , I like to use it in some projects ninja To compile the source code , Pay attention to ninja need cuda The version of at least 10.0 above .( and , When there is build.ninja This file , It indicates that the author has written the compiled version for you , Directly enter :ninja You can perform compilation ). The ultimate goal of the extension is to generate dynamic link libraries .so file
Two :cuda Version selection problem
pytorch choice cuda The order of versions is divided into :
1: Search order at compile time ;
①: Search for environment variables CUDA_HOME or CUDA_PATH( But in general , These two environment variables do not exist )( User and environment variable settings ~/.bashrc, System level environment variable settings /etc/profile; After modification, you need to use source Make changes , Otherwise, the modified content will not work )
②:/usr/local/cuda( This is actually a soft connection , That is to say, it is not the real one we need cuda, It's a goal that points to us cuda Link to , So we can easily change the version we need by modifying it )
③:which nvcc The parent directory of (which nvcc Will be in the environment variable PATH In looking for ,PATH Generally in ~/.bashrc Set in file , There may be more than one PATH Both contain nvcc The situation of , At this time, choose the first PATH Included in NVCC, It can be done by echo $PATH Check the setting of environment variables .), In general which nvcc The result is /usr/bin/nvcc, there nvcc The default point is the system default cuda, Generally, the version is relatively low , It can be modified to point to the version we need
Be careful ,nvcc -V and nvidia-smi Coming out cuda Version inconsistency , A corresponding drive API, A corresponding operation API, Let's see nvcc -V
④: If none of the above exists , be torch.utils.cpp_extension.CUDA_HOME by None, Will use conda Installed cudatoolkit, Its path is cudart The parent directory of the library file directory ( This may be through conda Installed cudatoolkit, General direct use conda install cudatoolkit, It's here that I found cuda Library ).
2: Search order when executing ( Search .so The order of the documents ): see Reference resources
3:pytorch Used at compile time cuda The version is available through :torch.version.cuda Check it out.
And at run time cuda The version is available through torch.utils.cpp_extension.CUDA_HOME Check it out. . Reference from cuda and cudatoolkit
3、 ... and :cuda/cudatoolkit/nvcc
Reference from :cuda and cudatoolkit
边栏推荐
- College entrance examination admission score line climbing
- Engineer evaluation | rk3568 development board hands-on test
- MySQL calculate n-day retention rate
- 解决BASE64Encoder报错的问题
- 6090. Minimax games
- [leetcode] 417 - Pacific Atlantic current problem
- 怎样从微信返回的json字符串中截取某个key的值?
- 2022 年辽宁省大学生数学建模A、B、C题(相关论文及模型程序代码网盘下载)
- 6092. 替换数组中的元素
- Bing. Site Internet
猜你喜欢

XPT2046 四线电阻式触摸屏
![[leetcode] 1905 statistics sub Island](/img/82/d2f7b829f5beb7f9f1eabe8d101ecb.png)
[leetcode] 1905 statistics sub Island

Solve the problem of frequent interruption of mobaxterm remote connection

4. Jctree related knowledge learning

Yolov5 code reproduction and server operation

动态规划入门二(5.647.62)
![[network security] network asset collection](/img/3e/6665b5af0dedfcbc7bd548cc486878.png)
[network security] network asset collection

【LeetCode】1254-统计封闭岛屿的数量

Bing. Com website

终于搞懂了JS中的事件循环,同步/异步,微任务/宏任务,运行机制(附笔试题)
随机推荐
XPT2046 四线电阻式触摸屏
SQL修改语句
List of sergeant schools
Engineer evaluation | rk3568 development board hands-on test
floyed「建议收藏」
目标检测—利用labelimg制作自己的深度学习目标检测数据集
LeetCode刷题——递增的三元子序列#334#Medium
6096. Success logarithm of spells and potions
fastjson List转JSONArray以及JSONArray转List「建议收藏」
【LeetCode】876-链表的中间结点
PostgresSQL 流复制 主备切换 主库无读写宕机场景
/bin/ld: 找不到 -llz4
LeetCode刷题——验证二叉树的前序序列化#331#Medium
【LeetCode】344-反转字符串
【LeetCode】695-岛屿的最大面积
(Video + graphic) machine learning introduction series - Chapter 5 machine learning practice
党史纪实主题公益数字文创产品正式上线
Thoroughly understand browser strong cache and negotiation cache
6090. 极大极小游戏
密码学基础知识