最近学习Swintransformer的时候,需要安装apex,官方安装指南。
git clone https://github.com/NVIDIA/apex
cd apex
pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./
可是按照如上的安装,出现如下错误:
RuntimeError: Cuda extensions are being compiled with a version of Cuda that does not match the version used to compile Pytorch binaries. Pytorch binaries were compiled with Cuda 10.1.
上述的意思是:cuda与Pytorch的版本不匹配,于是将上述的安装命令的后面部分去掉了,即
pip install -v --no-cache-dir ./
然后显示安装成功了。然后进入python,导入apex
import apex
第一次导入的时候,会出现:
`fused_weight_gradient_mlp_cuda` module not found. gradient accumulation fusion with weight gradient computation disabled.
当然这个问题的解决可以去github中apex的问题中,好像有解决途径,我没去解决(偷懒)。第二次导入apex的时候,将不会出现上述的问题。
import apex
现在,Swintransformer的代码也可以运行起来啦!如下图所示: