网络问题导致下载失败
pip install torch -i https://pypi.tuna.tsinghua.edu.cn/simple/。版本兼容性问题
No matching distribution found或安装后无法使用GPU。conda安装时指定CUDA版本,如:conda install pytorch cudatoolkit=11.3 -c pytorch。依赖库缺失
libssl-dev等库。apt安装缺失依赖,例如:sudo apt install libssl-dev libffi-dev。CUDA和cuDNN未正确识别
torch.cuda.is_available()返回False。nvcc --version。LD_LIBRARY_PATH包含CUDA路径,添加到~/.bashrc:export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH,然后执行source ~/.bashrc。虚拟环境切换问题
ImportError: No module named ‘_C’
build-essential)。RuntimeError: 版本不匹配
Input type and weight type should be the same等。DataLoader报错already started
num_workers设置为0,或升级PyTorch版本。显卡驱动问题
ubuntu-drivers devices查看推荐版本,用sudo apt install nvidia-driver-版本号安装。权限问题
--user参数安装,或添加sudo(不推荐,可能影响系统环境)。[1,2,3,4,5,6,7,8,9,10]