【环境配置】【bug调试】pytorch3d 安装
本文介绍了PyTorch3D库的安装方法。由于直接pip install pytorch3d会失败,提供了两种解决方案:使用conda安装(conda install pytorch3d -c pytorch3d)或通过pip安装Git仓库。重点解决了pip安装时可能遇到的"ModuleNotFoundError: No module named 'torch'"问题,这是由于
前言
pytorch 3d库,用于3d显示和处理
官方版本及安装指引如下
https://github.com/facebookresearch/pytorch3d/releases
https://github.com/facebookresearch/pytorch3d/blob/main/INSTALL.md
安装方式
直接pip install pytorch3d 是安装不上的,可以用以下方式
1、换成conda安装conda install pytorch3d -c pytorch3d
2、pip 安装
如果想让环境干净一点,可以使用pip 安装git仓库
代码如下
pip install "git+https://github.com/facebookresearch/pytorch3d.git"
#特定版本
pip install "git+https://github.com/facebookresearch/pytorch3d.git@stable"
pip install "git+https://github.com/facebookresearch/pytorch3d.git@v0.7.7"
但是可能会遇到No module named ‘torch’的问题,尽管自己的conda环境已经安装了torch,问题如下
这是由于环境没有隔离,pytorch3d 的 setup.py 会在“获取构建依赖”阶段 单独创建一个临时的 pip build-env,这个 build 环境里,并不会自动带上conda环境中的 torch,因此执行 import torch 就会失败,pip 构建隔离(PEP 517)导致的,不是 torch 不在你的环境,而是在 pytorch3d 的构建沙箱里 torch 不存在。
pip install 问题解决
禁用构建隔离
pip install git+https://github.com/facebookresearch/pytorch3d.git@v0.7.7 --no-build-isolation
或
git clone https://github.com/facebookresearch/pytorch3d.git
cd pytorch3d
git checkout v0.7.7
pip install . --no-build-isolation
其中v0.7.7是要安装的版本,可以在https://github.com/facebookresearch/pytorch3d/releases中获取你torch和python对应的版本
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐



所有评论(0)