記錄一個小坑
在學習深度學習時我們一般會在github上down大佬們的代碼,
然後用指令
pip install -U -r requirements.txt
來一次性安裝所需要的依賴環境,但有時系統會了解錯,比如requirements裡面寫的是torch>=1.7.0 torchvision>=0.8.1,pip自動安裝的是cpu版本,在cmd指令行用
torch.cuda.is_availiable()
指令發現問題不是gpu版本
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'torch.cuda' has no attribute 'is_availiable'
故需要在https://pytorch.org/get-started/locally/另外下。
當然建議你在跑别人代碼時最好先配置好基礎環境,再去pip install第三方的依賴包。