git clone https://github.com/NVIDIA/apex
cd apex
pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./
官方的安装方式。
但是安装会出错:
ERROR: Command errored out with exit status 1: 'D:\ScientificComputing\Anaconda3_64bit202007\envs\yolovx\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-req-build-jtqtkyh_\\setup.py'"'"'; __file__='"'"'C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-req-build-jtqtkyh_\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' --cpp_ext --cuda_ext install --record 'C:\Users\Administrator\AppData\Local\Temp\pip-record-2cch8kns\install-record.txt' --single-version-externally-managed --compile --install-headers 'D:\ScientificComputing\Anaconda3_64bit202007\envs\yolovx\Include\apex' Check the logs for full command output.
解决办法是
1、先检查本机cuda和pytorch的cuda是否适配。
nvcc -V
pytorch.cuda
我检查到是一样的
2、重新安装apex,去掉后面两个–cpp_ext,安装指令变成:
pip install -v --no-cache-dir ./
最后出现这段消息表示安装成功。原因我也不知道。原文连接。
Successfully built apex
Installing collected packages: apex
Successfully installed apex-0.1