cat /usr/local/cuda/version.txt
# 顯示結果:CUDA Version 10.0.130
# CUDA 10.0
conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch
# CUDA 10.0
pip install torch==1.2.0 torchvision==0.4.0 -f https://download.pytorch.org/whl/torch_stable.html
得到:
CUDA Version 11.0.228
然而,使用11.0版本不匹配,只能如下解決:
pc6上遇到此問題
torch
官網上找命令,使用pip安裝cuda11.1版本的。
pip3 install torch==1.8.2+cu111 torchvision==0.9.2+cu111 torchaudio==0.8.2 -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html
環境導出和安裝的命令
目前主機:
conda create -n env
pip批量導出包含環境中所有組件的requirements.txt文件
pip freeze > requirements.txt
pip批量安裝requirements.txt文件中包含的組件依賴
pip install -r requirements.txt
conda批量導出包含環境中所有組件的requirements.txt文件
conda list -e > requirements2.txt
conda批量安裝requirements.txt文件中包含的組件依賴
conda install --yes --file requirements2.txt
注:
首先,用pip安裝時,請先刪除掉所有torch的三條。
使用文中提到的torch安裝方法安裝。
之后,再安裝pip的其他軟件。