当前位置:网站首页>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
边栏推荐
猜你喜欢

SQL transaction

已知兩種遍曆序列構造二叉樹
![[development environment] install Visual Studio Ultimate 2013 development environment (download software | install software | run software)](/img/26/3f19d36c048e669c736e27384e0fa7.jpg)
[development environment] install Visual Studio Ultimate 2013 development environment (download software | install software | run software)

PostgresSQL 流复制 主备切换 主库无读写宕机场景

已知两种遍历序列构造二叉树

Leetcode skimming - remove duplicate letters 316 medium

Steps for Navicat to create a new database

终于搞懂了JS中的事件循环,同步/异步,微任务/宏任务,运行机制(附笔试题)

【Salesforce】如何确认你的Salesforce版本?

NBA player analysis
随机推荐
Finally, I understand the event loop, synchronous / asynchronous, micro task / macro task, and operation mechanism in JS (with test questions attached)
2303. 计算应缴税款总额
locate: 无法执行 stat () `/var/lib/mlocate/mlocate.db‘: 没有那个文件或目录
【LeetCode】19-删除链表的倒数第N个结点
解决BASE64Encoder报错的问题
【LeetCode】1020-飞地的数量
【Experience Cloud】如何在VsCode中取得Experience Cloud的MetaData
Leetcode skimming -- incremental ternary subsequence 334 medium
【LeetCode】486-预测赢家
数字藏品系统开发(程序开发)丨数字藏品3D建模经济模式系统开发源码
Leetcode skimming -- count the number of numbers with different numbers 357 medium
[leetcode] 417 - Pacific Atlantic current problem
[development environment] install the Chinese language pack for the 2013 version of visual studio community (install test agents 2013 | install visual studio 2013 simplified Chinese)
2279. 装满石头的背包的最大数量
Force deduction solution summary 2029 stone game IX
The task cannot be submitted after the installation of flick is completed
Build your own semantic segmentation platform deeplabv3+
怎样从微信返回的json字符串中截取某个key的值?
6.12 critical moment of Unified Process Platform
02. After containerization, you must face golang