当前位置:网站首页>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 crawler
- [leetcode] 200 number of islands
- SQL FOREIGN KEY
- 2022 年辽宁省大学生数学建模A、B、C题(相关论文及模型程序代码网盘下载)
- College entrance examination score line climbing
- 【LeetCode】344-反转字符串
- (Video + graphic) machine learning introduction series - Chapter 5 machine learning practice
- LeetCode刷题——奇偶链表#328#Medium
- Leetcode skimming -- incremental ternary subsequence 334 medium
- 03. Preliminary use of golang
猜你喜欢
LeetCode刷题——去除重复字母#316#Medium
【Salesforce】如何确认你的Salesforce版本?
SQL transaction
Equipped with Ti am62x processor, Feiling fet6254-c core board is launched!
Build your own semantic segmentation platform deeplabv3+
Yolov5 code reproduction and server operation
已知两种遍历序列构造二叉树
03. Preliminary use of golang
Beijing rental data analysis
Party History Documentary theme public welfare digital cultural and creative products officially launched
随机推荐
lseek 出错
Summary of the first three passes of sqli Labs
LeetCode刷题——递增的三元子序列#334#Medium
[leetcode] 167 - sum of two numbers II - enter an ordered array
/bin/ld: 找不到 -llz4
二叉树前,中,后序遍历
【LeetCode】1162-地图分析
2279. Maximum number of backpacks filled with stones
【LeetCode】283-移动零
locate: 无法执行 stat () `/var/lib/mlocate/mlocate.db‘: 没有那个文件或目录
Thoroughly understand browser strong cache and negotiation cache
The task cannot be submitted after the installation of flick is completed
6090. Minimax games
Pytoch saves tensor to Mat file
【LeetCode】200-岛屿数量
[leetcode] 1905 statistics sub Island
Storage read-write speed and network measurement based on rz/g2l | ok-g2ld-c development board
数组和链表的区别浅析
【LeetCode】486-预测赢家
Yolov5 code reproduction and server operation