【2023.9 update】
使用conda install pytorch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 cudatoolkit=11.0 -c pytorch
可能会遇到/lib/python3.6/site-packages/torch/lib/../../../../libcublas.so.11: symbol free_gemm_select version libcublasLt.so.11 not defined in file libcublasLt.so.11 with link time reference
的错误,解决方案Pytorch在RTX3090上模型建立非常慢的问题,可以使用pip install torch==1.7.1+cu110 torchvision==0.8.2+cu110 torchaudio===0.7.2 - f https://download.pytorch.org/whl/torch_stable.html
进行安装。
在安装pytorch的时候,如果服务器上有GPU,不能直接使用pip install pytorch==x.x
或conda install pytorch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 -c pytorch
,在这种情况下默认安装的是CPU版本的pytorch,因此如果使用GPU运行会出现CUDA版本不匹配的问题,即CUDA error: no kernel image is available for execution on the device。
按照官网的安装命令,如果需要安装GPU版本的pytorch,可以使用conda install pytorch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 cudatoolkit=11.0 -c pytorch
指定cudatoolkit的版本安装。
另,官网中给出了不同版本的pytorch对应的torchvision、torch audio和CUDA版本,十分实用。