跑github的深度学习demo时出现CUDA is *NOT* detected. Running with only CPU的解决方案
最近在跑一些demo的时候出现CUDA未见测到的问题:
因此笔者卸载重装了两次(NVIDIA驱动+CUDA+CUDNN),还是没有解决(重装3件套过程也很曲折,心态爆炸。。),因此再仔细看了下demo的README文件,其中有一句:
而笔者的pytorch是直接用pip install安装的,因此也是最新版本,所以报错: UserWarning: Default grid_sample and affine_grid behavior has changed to align_corners=False since 1.3.0. Please specify align_corners=True if the old behavior is desired. See the documentation of grid_sample for details.
所以打算通过
pip install torch==0.3.1 torchvision==0.2.0
进行安装,不过同样报错:
ERROR: Could not find a version that satisfies the requirement torch==0.3.1 (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2, 0.4.1, 0.4.1.post2, 1.0.0, 1.0.1, 1.0.1.post2, 1.1.0, 1.2.0, 1.3.0, 1.3.1, 1.4.0, 1.5.0, 1.5.1, 1.6.0)
ERROR: No matching distribution found for torch==0.3.1
去了一趟torch的官网发现:
并没有torch0.31的python3.7版本,笔者鉴于偷懒安了一个0.4.1的版本,结果还是报错:
KeyError: 'module name can\'t contain "."'
好吧。。。还是装python3.6(网上很多教程)。
**
最终的解决方案
**
1、安装python3.6设置为默认(包括安装所有需要的包);
2、通过命令
pip install torch==0.3.1 torchvision==0.2.0
安装torch0.3.1;
3、大功告成