配置CUDA-Pytorch全家桶问题记录
环境
1. ERROR: Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly
安装opencv-python时出现,伴随scikit-build could not get a working generator for your system. Aborting build.
解决:升级pip到最新版即可python -m pip install --upgrade pip
2. Building wheel for PyGlm (pyproject.toml) … error
error: subprocess-exited-with-error
× Building wheel for PyGlm (pyproject.toml) did not run successfully.
缺失了某些依赖模块,所以安装报错。
我的默认python版本是3.8,pyglm不支持了,换python版本到3.10解决。(直接把环境变量放最前面重新pip装一遍)
3. No CUDA runtime is found, using CUDA_HOME=‘C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8’
检查cuda: cuda不可用(torch.cuda.is_available()返回false)
重建一个conda环境安装pytorch:
先python -V
查看python版本,
再去pytorch官网复制下载链接安装pytorch;
如果有本地whl包:
cd [whl位置]
pip install torch-2.2.1+cu118-cp310-cp310-win_amd64.whl
4. Running setup.py install for diff-gaussian-rasterization … error
error: subprocess-exited-with-error
× Running setup.py install for diff-gaussian-rasterization did not run successfully.
原因就是上面的cuda没弄好,确保版本匹配。
5. UserWarning: Attempted to use ninja as the BuildExtension backend but we could not find ninja… Falling back to using the slow distutils backend.
pip install ninja
6. unsupported Microsoft Visual Studio version! Only the versions between 2017 and 2022
解决方法:
进入->C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\include\crt
在host_config.h
搜索
1 |
修改为
1 |
7. Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
服务器上运行Octo时遇到。
8. UserWarning: Error checking compiler version for cl: WinError 2 系统找不到指定的文件。
找不到cl.exe,这是一个类似编译器的东西,解决方法:先下载Visual Studio,再去安装目录找到附带的cl.exe,比如:
1 | D:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.42.34433\bin\Hostx86\x86\cl.exe |
把它所在位置加入系统环境变量,重启cmd输入:cl,有响应即成功。
9. AttributeError: module ‘torch.library’ has no attribute ‘register_fake’
原因:由于torch版本过高或者torchvision版本过低导致的不匹配。
版本对应表参考:PyTorch中torch、torchvision、torchaudio、torchtext版本对应关系
所以先看torch版本:
1 | pip list | grep torch |
再降级torchversion:
1 | pip install torchvision==0.17.0 |
但是降级完torchvision之后很可能发现pytorch本身又寄了(变成cpu版本),
所以再次回到上述第3条的位置,用本地whl重装一下gpu版本的pytorch,问题解决。
10. 终端中运行 conda install 命令后一直卡在Solving environment:
问题描述:正常创建激活环境,安装pytorch以及cuda:
1 | conda install pytorch==1.13.0 torchvision==0.14.0 torchaudio==0.13.0 pytorch-cuda=11.6 -c pytorch -c nvidia |
卡死在Solving environment:
解决思路:如果正在使用服务器,不要在无卡模式进行上述操作。
pytorch-cuda=11.6
会明确要求安装 CUDA 11.6 对应的 GPU 版本,Conda 在解析依赖时,可能会尝试检测系统的 GPU 或驱动支持,如果此时没有显卡(即Nvidia驱动)会卡死退出。
所以更换正常模式开机,清理缓存后重新装就可以了。
如果不是上述原因,其余排查思路:
- 更新conda:在base环境中执行
conda update conda
- 清理缓存:
conda clean --all
- AotuDL学术加速:
source /etc/network_turbo
- 查看源、删除原来的源、添加清华源:
1 | conda config --show |
上述清华源官方:https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
最好每次换源之前都查一下,确保使用最新的有效的链接。
代码
1. error : too few arguments for template template parameter Tuple
解决方案:
将cast.h中报错信息相应位置附近,注释掉以下内容
重新 python setup.py build 命令,编译通过
2. AttributeError module ‘time‘ has no attribute ‘clock‘
Python3.X版本之后不支持time.clock
,找到报错的文件用time.perf_counter()
替换掉time.clock
即可
3. os.mkdir()时出现FileNotFoundError: 系统找不到指定的路径
其中的一个原因是因为os.mkdir()
只能创建一级目录,应该用os.makedirs()
创建多级目录。将代码改为os.makedirs()
即可
4. RuntimeError: Program ‘ffmpeg’ is not found; perhaps install ffmpeg using ‘apt install ffmpeg’.
conda install ffmpeg -c conda-forge
连接好网络,注意看清楚安装成功。
RDK X5配置
1. RDK Studio添加设备后按教程无法连接wifi
一些wifi的安全策略似乎会阻止来自RDK Studio的连接,而RDK Studio不会报错。尝试使用ssh登录终端,然后使用以下命令手动连接:(WIFINAME和WIFIPASSWORD替换为wifi名称和密码)
1 | nmcli con add con-name "WIFINAME" ifname wlan0 type wifi ssid "WIFINAME" |
已测试成功: