【问题标题】:tensorflow-gpu conda environment not working on ubuntu-20.04tensorflow-gpu conda 环境不适用于 ubuntu-20.04
【发布时间】:2021-07-19 07:26:21
【问题描述】:

我按照说明在 ubuntu 20.04 上使用 conda 安装 tensorflow:Installing Tensorflow using Anaconda

conda create --name tf tensorflow-gpu

conda 环境已成功创建。但是 tensorflowgpu 不起作用:

 !18
python3 image_classification_efficientnet_fine_tuning.py
2021-04-25 13:08:58.235320: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
2021-04-25 13:08:58.235341: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Traceback (most recent call last):
  File "image_classification_efficientnet_fine_tuning.py", line 137, in <module>
    import tensorflow as tf
  File "/home/steve/.local/lib/python3.8/site-packages/tensorflow/__init__.py", line 436, in <module>
    _ll.load_library(_main_dir)
  File "/home/steve/.local/lib/python3.8/site-packages/tensorflow/python/framework/load_library.py", line 153, in load_library
    py_tf.TF_LoadLibrary(lib)
tensorflow.python.framework.errors_impl.NotFoundError: /home/steve/anaconda3/envs/tf/lib/python3.8/site-packages/tensorflow/core/kernels/libtfkernel_sobol_op.so: undefined symbol: _ZNK10tensorflow8OpKernel11TraceStringB5cxx11ERKNS_15OpKernelContextEb

使用 cuda 在 ubuntu-20.04 上安装 Tensorflow 非常困难。

【问题讨论】:

  • 这是迄今为止最难的部分。我强烈推荐使用pip 来安装tensorflow 而不是conda 包。请遵循官方指南。
  • 你可以关注this tutorial
  • @M.Innat 多次尝试 pip:包括重新安装整个 O/S 以提供新的尝试。看起来关键可能是选择 TF

标签: python tensorflow anaconda ubuntu-20.04


【解决方案1】:

TensorFlow创建virtual_environment后,您需要在该虚拟环境中安装TensorFlow

conda create -n tf-gpu tensorflow-gpu   # to create a virtual environment
conda activate tf-gpu                   # to activate the virtual environment

conda install tensorflow-gpu            # to install tensorflow-gpu

注意:每当您想运行TensorFlow 代码时,请在anaconda 中选择这个'tf-gpu' 虚拟环境。

在执行上述这些代码后再次尝试运行您的代码,如果问题仍然存在,请告诉我们。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-03-23
    • 2018-12-29
    • 2021-04-13
    • 2020-12-02
    • 1970-01-01
    • 2019-01-04
    • 1970-01-01
    • 2018-10-26
    相关资源
    最近更新 更多