【G3D笔记】AI生成式3D算法相关环境安装爬坑笔记

【G3D笔记】AI生成式3D算法相关环境安装爬坑笔记)

  • 1、 RayMarching
    • 1.1 error C1189: #error: You need C++17 to compile PyTorch
    • 1.2 raymarching安装环境版本测试
    • 1.3 host_config.h(231): fatal error C1083: 无法打开包括文件: “crtdefs.h”
  • 2、Tiny-Cuda-nn
    • 2.1 HTTP/2 stream 1 was not closed cleanly before end of the underlying stream
  • 3、Pytorch3D
    • 3.1 The detected CUDA version (12.1) mismatches the version that was used to compile PyTorch (11.8)
      • 3.1.1 win10 系统环境下解决方案
      • 3.1.2 Ubuntu 系统环境下解决方案
    • 3.2 安装Pytorch3D
      • 3.2.1 选择Python版本
      • 3.2.2 安装Pytorch库
      • 3.2.3 安装Pytorch库
      • 3.2.4 安装CUB库
      • 3.2.5 安装Pytorch3D
        • 3.2.5.1 Conda 安装 Pytorch3D
          • 3.2.5.1.1 Ubuntu 系统环境 (推荐此法安装)
          • 3.2.5.1.1 Win10 系统环境 (未找到安装包)
        • 3.2.5.2 PIP 安装 Pytorch3D
          • 3.2.5.2.1 Ubuntu 系统环境 (安装成功)
          • 3.2.5.2.2 Win10 系统环境 (安装成功)
    • 3.3 Pytorch相关
      • 3.3.1 无法定位程序输入点 ??0AutoGradMode@c10@@QEAA@_N@X于动态链接库
        • 3.3.1.1 问题分析
        • 3.3.1.2 解决方案
      • 3.3.2 DLL load failed while importing _C: 找不到指定的程序
        • 3.3.2.1 问题未解决
        • 3.3.2.2 再次尝试
        • 3.3.2.2 改变策略 (成功解决)
          • 3.3.2.2.1 方案1:强制carvekit使用2.0.1 (成功)
          • 3.3.2.2.1 方案2:升级carvekit使用2.0.1 (成功)
  • 4、其他
    • 4.1 PyMeshlab
      • 4.1.1 AttributeError: module ‘pymeshlab’ has no attribute ‘Percentage’
      • 4.1.2 pymeshlab版本问题 有可能关联的错误
    • 4.2 RuntimeError: Ninja is required to load C++ extensions
      • 4.2.1 FileNotFoundError: [WinError 2] 系统找不到指定的文件
        • 4.2.1.1 问题分析
        • 4.2.1.2 解决方案
  • 5、OpenGL (Ubuntu环境)
    • 5.1 RuntimeError: OpenGL 4.4 or later is required
      • 5.1.1 问题分析
      • 5.1.2 解决方案
    • 5.2 libEGL warning: MESA-LOADER: failed to open swrast
      • 5.2.1 问题分析
      • 5.2.2 解决方案
    • 5.3 libEGL warning: egl: failed to create dri2 screen(WSL2环境)
      • 5.3.1 问题分析
      • 5.3.2 解决方案 (暂未成功只做记录)

更新中…

本章是关于生成式AI3D相关算法环境搭建过程中的错误记录,涉及技术有:
raymarching:

Ray Marching 射线步进,一种用于实时场景的快速渲染方法,可以将SDF模型显示出来。

tiny-cuda-nn:

Tiny CUDA Neural Networks, 快如闪电的 C++/CUDA 神经网络框架,小型的、独立的框架,用于训练和查询神经网络。

PyTorch3D:

使用 3D 数据进行深度学习的库。

1、 RayMarching

1.1 error C1189: #error: You need C++17 to compile PyTorch

系统环境:win10

构建raymarching
python setup.py build_ext –inplace

raymarching.cu
C:/Users/USERT/miniconda3/envs/nerf2mesh/lib/site-packages/torch/include\c10/util/C++17.h(27): fatal error C1189: #error:  You need C++17 to compile PyTorch
nvcc warning : incompatible redefinition for option 'std', the last value of this option was used
raymarching.cu
ninja: build stopped: subcommand failed.

...

run_ninja_build(
  File "C:\Users\USERT\miniconda3\envs\nerf2mesh\lib\site-packages\torch\utils\cpp_extension.py", line 2112, in _run_ninja_build
    raise RuntimeError(message) from e
RuntimeError: Error compiling objects for extension

问题分析:
pytorch版本过高

解决方案:
conda install pytorch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 pytorch-cuda=11.8 -c pytorch -c nvidia

1.2 raymarching安装环境版本测试

系统环境:win10

Win 10 ver.21H
Python 3.9

通过测试
conda install pytorch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 pytorch-cuda=11.7 -c pytorch -c nvidia
conda install pytorch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 pytorch-cuda=11.8 -c pytorch -c nvidia
conda install pytorch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 pytorch-cuda=11.8 -c pytorch -c nvidia

未通过测试
conda install pytorch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 pytorch-cuda=12.1 -c pytorch -c nvidia

1.3 host_config.h(231): fatal error C1083: 无法打开包括文件: “crtdefs.h”

系统环境:win10

问题分析
Windows 10 SDK 未安装或版本不正确

解决方案
Visul Studio Community 2022 -> 工具 -> 获取工具和功能 -> 使用 C++ 的桌面开发 -> 可选 -> Windows 10 SDK (10.0.20348.0)
Windows 10 SDK (10.0.20348.0) == Windows 10 专业版 21H2

SDK对应WIN版本查询
https://developer.microsoft.com/zh-cn/windows/downloads/sdk-archive/

2、Tiny-Cuda-nn

Tiny CUDA Neural Networks

2.1 HTTP/2 stream 1 was not closed cleanly before end of the underlying stream

系统环境:win10

pip install git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple/
Collecting git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch
  Cloning https://github.com/NVlabs/tiny-cuda-nn/ to c:\users\usert\appdata\local\temp\pip-req-build-fydeqrnx
  Running command git clone --filter=blob:none --quiet https://github.com/NVlabs/tiny-cuda-nn/ 'C:\Users\USERT\AppData\Local\Temp\pip-req-build-fydeqrnx'
  fatal: unable to access 'https://github.com/NVlabs/tiny-cuda-nn/': HTTP/2 stream 1 was not closed cleanly before end of the underlying stream
  error: subprocess-exited-with-error

问题分析
网络不通

解决方案
需要梯子或接国内镜像

>pip install git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple/
Collecting git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch
  Cloning https://github.com/NVlabs/tiny-cuda-nn/ to c:\users\usert\appdata\local\temp\pip-req-build-ft7mgi0v
  Running command git clone --filter=blob:none --quiet https://github.com/NVlabs/tiny-cuda-nn/ 'C:\Users\USERT\AppData\Local\Temp\pip-req-build-ft7mgi0v'
  Resolved https://github.com/NVlabs/tiny-cuda-nn/ to commit 2ec562e853e6f482b5d09168705205f46358fb39
  Running command git submodule update --init --recursive -q
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: tinycudann
  Building wheel for tinycudann (setup.py) ... done
  Created wheel for tinycudann: filename=tinycudann-1.7-cp39-cp39-win_amd64.whl size=24754607 sha256=6d0047ec77071aff9b86908b512e7e613c85587ffe3b46d2d71880985ba69249
  Stored in directory: C:\Users\USERT\AppData\Local\Temp\pip-ephem-wheel-cache-ewyhba87\wheels\a9\17\8d\33c2914dcfb0b2fb1476d5d89ba4d3c896e5125178bdaeff3b
Successfully built tinycudann
Installing collected packages: tinycudann
Successfully installed tinycudann-1.7

3、Pytorch3D

3.1 The detected CUDA version (12.1) mismatches the version that was used to compile PyTorch (11.8)

3.1.1 win10 系统环境下解决方案

raise RuntimeError(CUDA_MISMATCH_MESSAGE.format(cuda_str_version, torch.version.cuda))
      RuntimeError:
      The detected CUDA version (12.1) mismatches the version that was used to compile
      PyTorch (11.8). Please make sure to use the same CUDA versions.

问题分析
当前环境的CUDA版本过高

>nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Wed_Feb__8_05:53:42_Coordinated_Universal_Time_2023
Cuda compilation tools, release 12.1, V12.1.66
Build cuda_12.1.r12.1/compiler.32415258_0
>conda list
pytorch                   2.1.0           py3.9_cuda11.8_cudnn8_0    pytorch

解决方案
我的电脑->属性->高级系统设置->环境变量
修改CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8

修改path中的C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin和libnvvp两项上移置顶

重启命令行窗口

nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Wed_Sep_21_10:41:10_Pacific_Daylight_Time_2022
Cuda compilation tools, release 11.8, V11.8.89
Build cuda_11.8.r11.8/compiler.31833905_0

3.1.2 Ubuntu 系统环境下解决方案

查看nvcc版本

$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Tue_Feb__7_19:32:13_PST_2023
Cuda compilation tools, release 12.1, V12.1.66
Build cuda_12.1.r12.1/compiler.32415258_0

查看系统中有哪些nvcc版本
已经安装cuda版本有我们需要的11.8

$ ll /usr/local | grep cuda
lrwxrwxrwx  1 root root   20 Mar 18 01:52 cuda -> /usr/local/cuda-12.1/
lrwxrwxrwx  1 root root   25 Apr 10  2023 cuda-11 -> /etc/alternatives/cuda-11/
drwxr-xr-x 14 root root 4096 Mar 18 01:37 cuda-11.6/
drwxr-xr-x 14 roo

版权声明:本文为博主作者:老富2012原创文章,版权归属原作者,如果侵权,请联系我们删除!

原文链接:https://blog.csdn.net/fuweipeng2012/article/details/136794036

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
扎眼的阳光的头像扎眼的阳光普通用户
上一篇 2024年4月1日
下一篇 2024年4月1日

相关推荐