linux conda 安装torch
时间: 2024-11-28 21:12:21 浏览: 46
在Linux系统上使用conda安装PyTorch,首先需要确保已经安装了Anaconda或者Miniconda,这是一个Python的数据科学平台,包含了包管理工具conda。以下是安装步骤:
1. 打开终端(Terminal)。
2. 检查并更新Conda:
```
conda update conda
```
3. 创建一个新的虚拟环境,这有助于隔离不同项目的依赖:
```bash
conda create -n torchenv python=3.8
```
这里假设你需要Python 3.8版本,如果不需要特定版本,则可以省略`python=3.8`。
4. 激活新创建的虚拟环境:
```
conda activate torchenv
```
5. 现在你可以通过conda安装PyTorch了,例如对于CPU版本:
```
conda install pytorch torchvision torchaudio cpuonly -c pytorch
```
如果你需要GPU支持,替换为:
```
conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch
```
请注意这里指定的CUDA版本应与你的显卡兼容。
6. 安装完成后,检查安装是否成功:
```bash
python -c "import torch; print(torch.__version__)"
```
阅读全文
相关推荐


















