在导入NVIDIA的apex库时报错 ImportError cannot import name ‘UnencryptedCookieSessionFactoryConfig‘ from
在導(dǎo)入NVIDIA的apex庫(kù)時(shí)報(bào)錯(cuò) ImportError: cannot import name ‘UnencryptedCookieSessionFactoryConfig’ from ‘pyramid.session’ (unknown location)
報(bào)錯(cuò)
在使用NVIDIA的apex庫(kù)時(shí)報(bào)錯(cuò) ImportError: cannot import name ‘UnencryptedCookieSessionFactoryConfig’ from ‘pyramid.session’ (unknown location)
筆者一開(kāi)始是使用的pip直接來(lái)安裝apex:
pip install apex但是在運(yùn)行時(shí)報(bào)錯(cuò):
Traceback (most recent call last):File "main.py", line 10, in <module>import apexFile "/home/ps/anaconda3/envs/JJ_env/lib/python3.8/site-packages/apex/__init__.py", line 13, in <module>from pyramid.session import UnencryptedCookieSessionFactoryConfig ImportError: cannot import name 'UnencryptedCookieSessionFactoryConfig' from 'pyramid.session' (unknown location)經(jīng)調(diào)查,原因是pip直接安裝的apex只是和我們想要安裝的NVIDIA的apex庫(kù)重名,但其實(shí)根本不是一回事兒。、
解決方案
從NVIDIA的github安裝apex庫(kù)
git clone https://github.com/NVIDIA/apex cd apex# 同時(shí)安裝C++擴(kuò)展 pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./# Apex 同樣支持 Python-only build (required with Pytorch 0.4) viapip install -v --no-cache-dir ./筆者使用帶C++擴(kuò)展的完全安裝時(shí)同樣會(huì)報(bào)錯(cuò),使用僅python安裝時(shí)顯示成功。
前者關(guān)鍵報(bào)錯(cuò)信息為:
ERROR: Command errored out with exit status 1: /users4/zsun/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-v0deounv/setup.py'"'"'; __file__='"'"'/tmp/p ip-req-build-v0deounv/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' --cpp_e xt --cuda_ext install --record /tmp/pip-record-rce1cb4d/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.評(píng)論區(qū)有朋友指出C++擴(kuò)展安裝的問(wèn)題可能是由于CUDA版本的原因,大家可參考。
參考:
https://stackoverflow.com/questions/66610378/unencryptedcookiesessionfactoryconfig-error-when-importing-apex
https://blog.csdn.net/ccbrid/article/details/103207676/
總結(jié)
以上是生活随笔為你收集整理的在导入NVIDIA的apex库时报错 ImportError cannot import name ‘UnencryptedCookieSessionFactoryConfig‘ from的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 汽车怠速断开装置类型?
- 下一篇: 杰克a4e电脑平车调针距调到最大车起来还