首页 > 解决方案 > 运行 TensorFlow 时出现问题(Ubuntu 19.10)

问题描述

我最近尝试从这个存储库安装和运行一些 python 和 tensorflow 代码。

我按照存储库中的 README.md 中提到的手动安装过程进行操作。

由于我以前从未使用过 tensorflow,因此我必须安装很多软件包才能启动并运行它。

目前,我的 Ubuntu 19.10 笔记本电脑上有 tensorfow-gpu 1.13、python 3.7 和 Nvidia 显卡 (mx250),我希望让代码运行。但是,我在运行demo.sh与它一起存在的文件时遇到问题。

这是我在$ bash demo.sh > output.txt 2> err.txt克隆目录中运行命令时在 err.txt 中得到的内容(在安装所有必需的软件包之后):

*** Aborted at 1575094215 (unix time) try "date -d @1575094215" if you are using GNU date ***
PC: @     0x7f92c7012ae8 ceres::internal::ProgramEvaluator<>::Evaluate()
*** SIGSEGV (@0x0) received by PID 22202 (TID 0x7f92acda5700) from PID 0; stack trace: ***
    @     0x7f92c7452641 (unknown)
    @     0x7f92c67dd540 (unknown)
    @     0x7f92c7012ae8 ceres::internal::ProgramEvaluator<>::Evaluate()
    @     0x7f92c709265f ceres::internal::TrustRegionMinimizer::EvaluateGradientAndJacobian()
    @     0x7f92c7092f4a ceres::internal::TrustRegionMinimizer::IterationZero()
    @     0x7f92c70972d4 ceres::internal::TrustRegionMinimizer::Minimize()
    @     0x7f92c7088cbc ceres::Solver::Solve()
    @     0x7f92c70899b9 ceres::Solve()
    @     0x55bb3bb1a2eb colmap::BundleAdjuster::Solve()
    @     0x55bb3bb78037 colmap::IncrementalMapper::AdjustGlobalBundle()
    @     0x55bb3bac3f0c (unknown)
    @     0x55bb3bac521d colmap::IncrementalMapperController::Reconstruct()
    @     0x55bb3bac6a9b colmap::IncrementalMapperController::Run()
    @     0x55bb3bbd7dfc colmap::Thread::RunFunc()
    @     0x7f92c5ad9f74 (unknown)
    @     0x7f92c67d1669 start_thread
    @     0x7f92c578f323 clone
Traceback (most recent call last):
  File "imgs2poses.py", line 11, in <module>
    gen_poses(args.scenedir)
  File "/home/abhigyan/Code/CVProject/LLFF/llff/poses/pose_utils.py", line 265, in gen_poses
    run_colmap(basedir)
  File "/home/abhigyan/Code/CVProject/LLFF/llff/poses/colmap_wrapper.py", line 70, in run_colmap
    map_output = ( subprocess.check_output(mapper_args, universal_newlines=True) )
  File "/home/abhigyan/anaconda3/lib/python3.7/subprocess.py", line 395, in check_output
    **kwargs).stdout
  File "/home/abhigyan/anaconda3/lib/python3.7/subprocess.py", line 487, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['colmap', 'mapper', '--database_path', 'data/testscene/database.db', '--image_path', 'data/testscene/images', '--output_path', 'data/testscene/sparse', '--Mapper.num_threads', '16', '--Mapper.init_min_tri_angle', '4', '--Mapper.multiple_models', '0', '--Mapper.extract_colors', '0']' died with <Signals.SIGSEGV: 11>.
Traceback (most recent call last):
  File "/home/abhigyan/anaconda3/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/home/abhigyan/anaconda3/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/home/abhigyan/anaconda3/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/home/abhigyan/anaconda3/lib/python3.7/imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "/home/abhigyan/anaconda3/lib/python3.7/imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: libcublas.so.10.0: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "imgs2mpis.py", line 10, in <module>
    from llff.inference.mpi_utils import run_inference
  File "/home/abhigyan/Code/CVProject/LLFF/llff/inference/mpi_utils.py", line 6, in <module>
    from llff.inference.mpi_tester import DeepIBR
  File "/home/abhigyan/Code/CVProject/LLFF/llff/inference/mpi_tester.py", line 1, in <module>
    import tensorflow as tf
  File "/home/abhigyan/anaconda3/lib/python3.7/site-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "/home/abhigyan/anaconda3/lib/python3.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/home/abhigyan/anaconda3/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/home/abhigyan/anaconda3/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/home/abhigyan/anaconda3/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/home/abhigyan/anaconda3/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/home/abhigyan/anaconda3/lib/python3.7/imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "/home/abhigyan/anaconda3/lib/python3.7/imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: libcublas.so.10.0: cannot open shared object file: No such file or directory


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/errors

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.
mkdir: cannot create directory ‘data/testscene/outputs/’: File exists
Traceback (most recent call last):
  File "imgs2renderpath.py", line 34, in <module>
    poses, bds = load_data(args.scenedir, load_imgs=False)
  File "/home/abhigyan/Code/CVProject/LLFF/llff/poses/pose_utils.py", line 195, in load_data
    poses_arr = np.load(os.path.join(basedir, 'poses_bounds.npy'))
  File "/home/abhigyan/anaconda3/lib/python3.7/site-packages/numpy/lib/npyio.py", line 428, in load
    fid = open(os_fspath(file), "rb")
FileNotFoundError: [Errno 2] No such file or directory: 'data/testscene/poses_bounds.npy'
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
demo.sh: line 24: 22221 Aborted                 (core dumped) cuda_renderer/cuda_renderer data/testscene/mpis_360 data/testscene/outputs/test_path.txt data/testscene/outputs/test_vid.mp4 360 .8 18

标签: python-3.xtensorflowubuntunvidia

解决方案


当您要在 GPU 设置中使用 Tensorflow 时,必须在您的机器中仔细安装和配置 Tensorflow。我更喜欢使用 Ubuntu 18.04 LTS 版本而不是 19.xx。

按照博客中的安装步骤:https ://zhuanlan.zhihu.com/p/49166211


推荐阅读