MVSNet代码复现问题解决、cuBlas call failed status=13问题

简介

这篇文章记录复现MVSNet中遇到的一些问题。

最近在复现 MVSNet 的代码,是一篇2018年的论文,使用的是tensorflow-gpu>=1.5的代码

源码中是建议使用cuda9.0和cudnn7.0,因此根据tensorflow和cuda的版本对应,只能安装1.5~1.12版本的,最后选择安装了1.5的gpu版本tensorflow。

服务器上的CUDA版本是11.2的,所以需要安装一个CUDA9.0,因为是在一起使用的服务器,所以CUDA9.0安装在个人目录下,而不是系统中,并可以在后续通过改变环境变量,来随意更换CUDA的版本。

非root用户下安装多个版本的CUDA和cuDNN参考下面的文章,非常保姆级的教程

https://blog.csdn.net/hizengbiao/article/details/88625044

MVSNet代码复现问题解决、cuBlas call failed status=13问题

注:tensorflow与cuda版本对应的官方版

; 代码小问题更改:

安装好tensorflow、cuda、cudnn以及其他的一些包后,运行代码会报一堆的错误

这些错误是因为不同版本的一些代码可能会有一些差异,函数名称和返回值可能会发生变化,因此需要更改一些有问题的代码。

[En]

These errors are because there may be some differences in some code in different versions, and the function name and return value may change, so change some problematic code.

1)tf.compat.v1.logging —> tf.logging


tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)

tf.logging.set_verbosity(tf.logging.ERROR)

2)tf.random.shuffle —> tf.random_shuffle

参考:https://stackoverflow.com/questions/59017361/attributeerror-module-tensorflow-has-no-attribute-random-shuffle
但是该链接中,问题是刚好反过来的,是1.x版本的代码运行在2.x版本的tf上。


indices = tf.random.shuffle(indices)

indices = tf.random_shuffle(indices)

3)train.py:train()中读取图像后image是五维的,但是per_image_standardization函数输入是四维的,所以在传入image之前先进行squeeze,再讲标准化后的image进行expand_dims扩展维度。

for view in range(0, FLAGS.view_num):
    image = tf.squeeze(tf.slice(images, [0, view, 0, 0, 0], [-1, 1, -1, -1, 3]), axis=1)
    if FLAGS.online_augmentation:
        image = tf.map_fn(online_augmentation, image, back_prop=False)

    image = tf.squeeze(image, axis=0)

    image = tf.image.per_image_standardization(image)

    image = tf.expand_dims(image, 0)

    arg_images.append(image)
images = tf.stack(arg_images, axis=1)

4)validate.py:validate_mvsnet(),与上面3)中的问题相同

for view in range(0, FLAGS.view_num):
    image = tf.squeeze(tf.slice(images, [0, view, 0, 0, 0], [-1, 1, -1, -1, 3]), axis=1)

    image = tf.squeeze(image, axis=0)

    image = tf.image.per_image_standardization(image)

    image = tf.expand_dims(image, 0)

    normalized_images.append(image)
images = tf.stack(normalized_images, axis=1)

5)photometric_augmentation.py:motion_blur(),将tf.numpy_function—>tf.py_func

参考:https://blog.csdn.net/qq_27825451/article/details/106376173


blurred = tf.numpy_function(_py_motion_blur, [image], tf.float32)

blurred = tf.py_func(_py_motion_blur, [image], tf.float32)

CUDA和显卡不兼容

修改代码后,执行:

[En]

After the code has been modified, execute:

CUDA_VISIBLE_DEVICES=2,3 python train.py --regularization '3DCNNs' --train_dtu --max_w 640 --max_h 512 --max_d 128 --dtu_data_root "../data/dtu/training/dtu" --log_folder "../log/dtu" --model_folder "../model/dtu" --num_gpus 2

您可以运行,但它会报告错误,这不是代码的错误。我忘了在我报告错误的地方截图。近似误差为:

[En]

You can run, but it will report an error and it is not an error of the code. I forgot to take a screenshot where I reported the error. The approximate error is:

cuBlas call failed status=13

在网上查找错误的解决方式,意思就是CUDA的版本与显卡不匹配:

参考:
https://www.zhihu.com/question/424656505
https://tieba.baidu.com/p/7045399988

有几种解决方案:
1)更换到更老的显卡上,即支持CUDA9.0的显卡
2)改代码,将代码重构为tensorflow2.x的版本,这个版本需要适配新的显卡可以支持的CUDA。(不推荐)
3)使用docker

自己使用的服务器的显卡是3090,只支持11.0以上的CUDA,甚至11.0都不太稳定,而我们的代码已经比较老了,能跑的tensorflow版本最高也就对应CUDA 10.0,所以没有办法,只能更换到老服务器上,使用1080ti进行实验。

在网上也搜到了其他的方法,能够在3090上跑tf1.5的代码,就是使用docker,这个我没有尝试,有时间的小伙伴可以参考这篇文章尝试一下:https://zhuanlan.zhihu.com/p/341969571

MVSNet后处理:使用Fusibile生成点云的代码问题

转到老服务后,把CUDA9.0和tensorflow1.5安装好,MVSNet的代码就可以跑通了。

MVSNet生成的是多个视图的深度图,为了生成点云,还需要一些后处理,作者使用了 fusibile 的代码实现点云的生成,代码是用C++写的,需要编译生成一个可执行文件,将该可执行文件的路径传到MVSNet的depthfusion.py中,完成后处理工作。

编译fusibile代码只需要两个前置要求:1)cuda>=6.0;2)opencv

刚刚已经安装了CUDA9.0,在编译的过程中提示需要opencv,在老服务上安装opencv非常顺利,没有任何错误,然后再次cmake成功了,但是在make的时候,提示代码不支持6.0以后的gnu的版本,老服务器上的gcc和g++版本是7.4,因为fusibile是2015年论文的代码,所以还需要安装一个6以下版本的gcc和g++。

在安装gcc的过程中,折腾了大半天,这一篇文章完全写不下,后续会写在另一篇文章中,在其中会介绍:
1)opencv安装过程、错误的排查
2)gcc安装过程、错误的排查
3)fusibile代码复现过程、错误解决
4)各种小问题的排查
这篇文章还没有写完,所以在这里放一个空链接:

[En]

The article hasn’t been written yet, so put an empty link here:

Original: https://blog.csdn.net/qq_41340996/article/details/121442567
Author: KyrieLiu52
Title: MVSNet代码复现问题解决、cuBlas call failed status=13问题

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/511974/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球