1660ti系列以上显卡gpu版本pytorch安装指令
时间: 2024-10-06 21:03:19 浏览: 45
如果你想在拥有NVIDIA GeForce GTX 1660 Ti及以上显卡的系统上安装PyTorch,你需要首先确保你的CUDA和cuDNN库是最新的。以下是安装步骤:
1. **更新操作系统**:
- 对于Ubuntu/Debian: `sudo apt-get update && sudo apt-get upgrade`
- 对于 CentOS/Fedora: `sudo yum update`
2. **安装必要的库**:
```bash
# 安装CUDA (替换`<version>`为你需要的CUDA版本)
wget https://developer.nvidia.com/compute/cuda/<version>/repo/deb/x86_64/cuda-repo-deb_<version>_<os_name>-11-0-local.gpg.key
sudo apt-key add cuda-repo-deb_<version>_<os_name>-11-0-local.gpg.key
echo "deb [arch=compute_{arch}]{cuda_url}/stable-{os_name}/{cuda_version}-local /" | sudo tee /etc/apt/sources.list.d/cuda.list
whereis libcudart.so > /dev/null || { echo "You need to install CUDA development package"; exit 1; }
sudo apt-get update
sudo apt-get install cuda
# 安装cuDNN (同样替换版本号)
sudo apt-get install libcudnn7 libcudnn7-dev
```
3. **安装PyTorch**:
- 首先,添加apt-pytorch-nightly源:
```bash
curl https://raw.githubusercontent.com/pytorch/get-torch/main/install.sh | bash -s -- <CUDA_VERSION>
```
- 然后安装PyTorch:
```bash
python3 -m torch.cuda.set_device 0 # 设定GPU设备为0
python3 -m pip install torch torchvision torchaudio -f https://download.pytorch.org/whl/cpu/torch_stable.html # CPU版本依赖
python3 -m pip install torch torchvision torchaudio -f https://download.pytorch.org/whl/cu<cuda_version>/torch_stable.html # GPU版本依赖
```
4. **检查安装**:
```bash
python -c "import torch; print(torch.__version__, torch.cuda.is_available())"
```
阅读全文