三维渲染mitsuba2安装 | git clone下载过慢问题 | 使用镜像源快速安装submodule

Mitsuba2:https://mitsuba2.readthedocs.io/

                   https://github.com/mitsuba-renderer/mitsuba2

 

官方安装:

## 从github上clone一个子仓库,不能直接download .zip,否则编译不成功

### Cloning the repository ###
git clone --recursive https://github.com/mitsuba-renderer/mitsuba2

## 如果没有输入--recursive则只下载了主仓库,而没有下载子模块, 则输入以下语句递归的安装子模块
## git submodule update --init --recursive

## 使仓库保持更新
git config --global alias.pullall '!f(){ git pull "$@" && git submodule update --init --recursive; }; f'
git pullall

### Compiling the systems ###
## for Linux
sudo apt install -y clang-9 libc++-9-dev libc++abi-9-dev cmake ninja-build
sudo apt install -y libz-dev libpng-dev libjpeg-dev libxrandr-dev libxinerama-dev libxcursor-dev
sudo apt install -y libz-dev libpng-dev libjpeg-dev libxrandr-dev libxinerama-dev libxcursor-dev

## for running tests
sudo apt install -y python3-pytest python3-pytest-xdist python3-numpy
sudo apt install -y python3-sphinx python3-guzzle-sphinx-theme python3-sphinxcontrib.bibtex

## 指定CXX环境
sudo gedit ~/.bashrc
在末尾加上:
export CC=clang-9
export CXX=clang++-9
更新环境:
source ~/.bashrc

## 开始编译
cd mitsuba2
mkdir build
cd build
cmake -GNinja ..
ninja

## Running mitsuba
source setpath.sh
# 测试是否可以导入:
python
import mitsuba

但是!由于mitsuba是个非常大型的项目,正常使用git clone非常之慢5Kb/s,中间不停的fatal、failed,如何提高git clone速度呢?
网上说的改端口地址对我的情况没有任何帮助,遂考虑使用镜像,一些可以参考的博文:

十种方法提高git clone速度

https://zhuanlan.zhihu.com/p/111697412

https://github.com/Sicmatr1x/Free-Resource/blob/master/Development.md

本git小白摸索了一晚上的解决方案!!!

(1)git限制了推送数据的大小,重新设置全局的通信缓存大小

git config --global http.postBuffer 524288000

但收效甚微

(2)Step1:

尝试先下载主仓库(以下方法都有效):

## 原本递归全下载的语句:
git clone --recursive https://github.com/mitsuba-renderer/mitsuba2
## 原本仅下载主仓库的语句:
git clone https://github.com/mitsuba-renderer/mitsuba2

## 方法一:添加github镜像

git clone https://github.com.cnpmjs.org/mitsuba-renderer/mitsuba2
# 此方法中如果加了--recursive会发现最开始下载主仓库很快,但子模块还是很慢下不了

## 方法二:利用gitclone.com
git clone https://gitclone.com/github.com/mitsuba-renderer/mitsuba2

这两种方法发现速率都在1+Mb/s以上,5秒完成(流泪)

(2)step2:

接着是解决子模块的下载,我们需要递归的下载子模块:

## 递归下载子模块的方法
git submodule update --init --recursive

1. 子模块的下载地址是在仓库的根目录下有一个.gitmodules的文件,里面保存了所有我们需要clone的子模块的地址,打开(表面上看不到)它:
sudo gedit .gitmodules
发现里面所有的地址还是github.com,这也就是为什么我们在利用镜像或者gitclone.com的时候不能用--recursive的原因,这会默认使用github.com的地址下载子模块

2. !!!!!!!还没有结束!!!!!!!之前我就只是改了.gitmodules发现部分报错
## sudo gedit .git/config(发现这里面的都还没有镜像,全是/github.com/)发现还是有一部分报错
使用以下指令将新的URL更新到文件.git/config
git submodule sync

3. 然后就很简单啦~我们把所有的地址像clone主仓库一样,全部改成利用镜像或者gitclone.com。不知道为什么我使用gitclone.com这个会clone失败,所以我采取了添加镜像后缀的方法

4. 运行:
git submodule update --init --recursive

5. 一开始会和正常不一样,出现很多语句,例如:
Submodule ‘ext/asmjit’ (https://github.com.cnpmjs.org/mitsuba-renderer/asmjit) registered for path 'ext/asmjit'
就是表达这个子模块的clone地址改变成我们现在使用的了

6. 然后就是等待(整个过程就很折磨),而且发现部分还是会报错,git pullall部分子模块也失败了
后来发现git submodule sync仅能更改当前已下载下来的.gitmodules
但是子模块中在colne的时候其内部还有子模块,里面的.gitmodules的地址是原始的github.com
于是更新子模块中子模块的clone地址,mitsuba2中包括:
ext/enoki/.gitmodules
ext/nanogui/.gitmodules
ext/pybind11/.gitmodules
ext/nanogui/ext/.gitmodules
所有的都需要:
git submodule sync

后来明白了其实就应该去github上的仓库看,那些文件上有一个箭头的就是需要clone的,甚至是别人的别人的代码,看到有.gitmodule的都需要修改里面的clone路径

7. 按照上述方法递归的安装子模块的子模块:git submodule update --init --recursive

这样下来所有的子模块以及子模块的子模块都被clone完毕,可以git pull成功啦

思考:如果在安装子模块的时候不加递归语句:--recursive,是不是不会自动安装子模块中的子模块?这样是不是就不会报错,我们只需要进去ext中修改一下子模块中的.gitmodules让它再跑一次

 

注:运行的时候会报错:没有ldrfilm.so

但通过查找文件夹里发现有一个取名字很像的hdrfilm.so在build/dist/plugins,把这个文件名字改成ldrfilm.so

竟然就成功了!渲染出来的也是正常的T T终于装好了哭哭

  • 7
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值