解决torch.cuda.is_available()返回False问题
错误如下;
错误原因:
在Pytorch官网使用命令
conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=11.1 -c pytorch -c conda-forge
下载的pytorch是默认为CPU的
解决办法:
不用conda
命令下载,使用pip
命令。
pip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 torchaudio==0.8.0 -f https://download.pytorch.org/whl/torch_stable.html
安装成功如下图:
此时,使用conda list
查看包如下图:
发现没有了**【cpuonly】**,再用torch.cuda.is_available()
命令查看,结果如下: