抱歉,您的浏览器无法访问本站
本页面需要浏览器支持(启用)JavaScript
了解详情 >

因为项目需要学习了Relightable Neural Rendering, 并尝试把源码下载到本地配置环境运行,被pytorch环境折磨的不轻,把最后成功的过程在这里放一下。

原仓库中记录的环境是Ubuntu 16.04 + CUDA 9.0 + gcc 4.9.2 + Anaconda 3,但因为手边没有合适的Linux服务器,所以使用windows环境配置,版本太老的cuda目前已经找不到合适的pytorch支持,最后使用的环境是window 10 + python3.9.16 + pytorch 1.13.0 + cuda 11.7 + anaconda 3,在两台windows系统电脑上都成功跑通了:一台是双3090,一台是1650。

环境配置过程

原仓库提供的environment环境文件太过杂乱,有很多不必要一一匹配的包,并且其中有很多版本都太老了已经无从下载,因此安装的时候就没有管这个environment了。
首先在官网安装cuda11.7版本,anaconda新建一个python3.9的环境,安装pytorch1.13.0,安装命令为:

1
conda install pytorch==1.13.0 torchvision==0.14.0 torchaudio==0.13.0 pytorch-cuda=11.7 -c pytorch -c nvidia

安装后需要进行的步骤为:

  1. 安装opencv:conda install opencv
  2. 安装trimesh:conda install -c conda-forge trimesh
  3. 安装torch-geometric。这里参考了:https://blog.csdn.net/xiangfengl/article/details/120254867#%E5%AE%89%E8%A3%85torch-%20geometric
    1
    2
    3
    4
    5
    pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.13.0%2Bcu117.html
    pip install torch-sparse -f https://pytorch-geometric.com/whl/torch-1.13.0%2Bcu117.html
    pip install torch-cluster -f https://pytorch-geometric.com/whl/torch-1.13.0%2Bcu117.html
    pip install torch-spline-conv -f https://pytorch-geometric.com/whl/torch-1.13.0%2Bcu117.html
    pip install torch-geometric
  4. pip install pyshtools
  5. pip install openexr
  6. conda install tensorboardX
  7. pip install pytorch_msssim

与此同时,源码需要做的修改:

  1. nerural-renderer模块中,rasterize_cuda_kernel.cu中,将
    #if __CUDA_ARCH__ < 600 and defined(__CUDA_ARCH__)修改为#if __CUDA_ARCH__ < 600 && defined(__CUDA_ARCH__)
  2. 将源码cuda文件夹下所有的代码中的AT_CHECK替换为TORCH_CHECK
  3. 在precompute.py, stitch_lp.py, train_rnr.py三个文件开头添加:
    1
    2
    import os
    os.environ['OPENCV_IO_ENABLE_OPENEXR'] = 'TRUE'
  4. np.int修改为np.int_
  5. 由于在windows系统下,将num_workers = 8修改为num_workers = 0
  6. 把train_rnr.py 中的 if opt.exp_name is not '': 修改为 if opt.exp_name != '':
  7. 使用windows系统,需要把sh文件修改为bat文件,在线转换工具:https://daniel-sc.github.io/bash-shell-to-bat-converter/

评论