首页 > 解决方案 > 没有名为 torch.distributed 的模块

问题描述

ImportError:没有名为 torch.distributed 的模块

File "train.py", line 4, in <module>
    import torch.distributed as dist
ImportError: No module named torch.distributed

我安装了 CUDA 和 cuDNN 然后创建了 env 并安装了 pip3 install torch torchvision 但出现错误。

标签: google-cloud-platformpytorch

解决方案


这对我有用:

  1. 创建 conda 虚拟环境:

    conda create -n env_pytorch python=3.6
    
  2. 在上面创建这个环境:

    source activate env_pytorch
    
  3. 使用 pip 或 pip3 安装 PyTorch:

    pip install torchvision --user
    

推荐阅读