win下配置pytorch3d

一、配置好的环境:py 3.9 + pytorch 1.8.0 + cuda 11.1_cudnn 8_0 + pytorch3d 0.6.0 + CUB 1.11.0

你可能觉得pytorch3d 0.6.0版本有点低,但是折腾不如先配上用了,以后有需要再说。
(后话:py 3.9 + pytorch 1.12.1 + cuda 11.3_cudnn 8_0 + pytorch3d 0.7.1 + CUB 1.11.0 也OK的)

1.1 创建新环境

conda create -n torch3Dtorch180 python=3.9
conda activate torch3Dtorch180

1.2 找之前的pytorch版本,我这里直接给出我的选择的版本

# CUDA 11.1
conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=11.1 -c pytorch -c conda-forge

一行行复制粘贴运行下面的命令

conda install -c fvcore -c iopath -c conda-forge fvcore iopath
conda install jupyter
pip install scikit-image matplotlib imageio plotly opencv-python
pip install black usort flake8 flake8-bugbear flake8-comprehensions

1.3 下载对应的pytroch3d,Version 0.6.0

win下配置pytorch3d_第1张图片
解压后,在pytorch3d中源码修改以下:

1.3.1 setup.py 中43行:

extra_compile_args = {"cxx": ["-std=c++14"]},改为extra_compile_args = {"cxx": []}

1.3.2 setup.py 中60行:

-std=c++14那行注释掉

1.3.3 pytorch3d/csrc/iou_box3d.cu 18行:

#include "utils/pytorch3d_cutils.h" 那行注释掉

1.3.4 pytorch3d/csrc下,iou_utils.cuh和 iou_utils.h 中搜索not

像下面的这种语句中,把not改为!
win下配置pytorch3d_第2张图片

1.3.5 在你环境中的torch\utils\cpp_extension.py中

本人的是E:\01_softwares\07_Anaconda3\install\envs\torch3Dtorch180\Lib\site-packages\torch\utils\cpp_extension.py

match = re.search(r'(\d+)\.(\d+)\.(\d+)', compiler_info.decode().strip())中加入 "gbk"
在这里插入图片描述

1.4 下载对应的 CUB

具体的CUB与cuda toolkit对应关系见 https://github.com/NVIDIA/cub,这里我下载的是CUB 1.11.0
在这里插入图片描述

在这里插入图片描述
同样的解压到你想要的位置,添加设置环境变量,变量名CUB_HOME,变量值即为刚才解压的cub的文件路径
win下配置pytorch3d_第3张图片


二、安装CUDA ToolKit 11.3

这部分参考:https://blog.csdn.net/weixin_43469047/article/details/130170756?spm=1001.2014.3001.5501


三、下载VS2019

如果你有VS2022,大可以先试试,不行再下VS2019。


四、最后的配置

搜索x64即可找到x64 Native Tools Command Prompt for VS 2019终端,切换路径和虚拟环境。
win下配置pytorch3d_第4张图片
依次执行下面命令:

set DISTUTILS_USE_SDK=1
set PYTORCH3D_NO_NINJA=1

最后执行安装pytorch3D的代码

python setup.py install

等待10分钟,就装好了
win下配置pytorch3d_第5张图片


以上参考自:
《pytorch3D Windows下安装经验总结》
《win10系统下安装PyTorch3d》


总结一些问题:

1、

win下配置pytorch3d_第6张图片
可能的解决方案:使用VS2019而不是VS2022,VS2019的具体小版本倒无所谓,因为我去找community社区版也只有最后一版可供下载了。
参考自:https://github.com/facebookresearch/pytorch3d/issues/1024


你可能感兴趣的:(软件管理,pytorch3d)