在使用 apex 庫時,按照官方的方式安裝后,雖然安裝成功,但調用的時候會報錯如下,也就是說其實沒有成功安裝可調用 cuda 的 apex:
RuntimeError: apex.optimizers.FusedSGD requires cuda extension
我找了很多解決方式,最終通過如下方式解決:
git clone https://github.com/NVIDIA/apex.git
cd apex
git checkout 22.04-dev
pip install -v --no-cache-dir --global-option="--pyprof" --global-option="--cpp_ext" --global-option="--cuda_ext" ./