You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Anaconda环境运行MeshCNN遇torch._C属性错误及CUDA安装问题求助

问题描述
  • 运行MeshCNN项目时,通过项目附带的.yml文件在Anaconda创建环境后,出现CUDA相关安装错误
  • 执行conda install -c anaconda cudatoolkit=10.1解决前序错误后,触发AttributeError: module 'torch._C' has no attribute '_cuda_setDevice'错误,涉及train.py、base_option.py、init.py文件
  • 尝试执行pip install torch===1.9.0+cu111 torchvision===0.10.0+cu111 torchaudio===0.9.0 -f https://download.pytorch.org/whl/cu111/torch_stable.html安装PyTorch时,下载过程报错
解决方案

1. 匹配CUDA版本安装对应PyTorch

你安装的cudatoolkit是10.1,但尝试安装的PyTorch是适配CUDA 11.1的版本,二者不兼容,这是导致_cuda_setDevice属性错误的核心原因。按以下步骤操作:

  • 先卸载当前不兼容的PyTorch组件:
    pip uninstall torch torchvision torchaudio -y
    
  • 使用conda安装适配CUDA 10.1的PyTorch版本(推荐用conda避免依赖冲突):
    conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=10.1 -c pytorch
    
    该版本组合经过官方验证,与CUDA 10.1完全兼容。

2. 验证环境配置

安装完成后,运行以下代码确认PyTorch与CUDA是否正常联动:

import torch
print(torch.cuda.is_available())
print(torch.version.cuda)

若输出True和10.1,说明配置成功。

3. 解决下载慢/报错问题

如果conda下载速度慢或失败,切换国内镜像源后重试:

  • 添加清华Anaconda镜像源:
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
    conda config --set show_channel_urls yes
    
    配置完成后重新执行PyTorch安装命令即可。

4. 重新运行项目

激活你的Anaconda环境:

conda activate 你的环境名称

之后即可正常运行MeshCNN的训练脚本。

内容的提问来源于stack exchange,提问作者paulaHb03

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.24 04:05:23