【问题标题】:Do I Need to Reinstall Tensorflow everytime I join a virtualenv?每次加入 virtualenv 时都需要重新安装 Tensorflow 吗?
【发布时间】:2020-07-20 23:41:30
【问题描述】:

所以我按照本教程https://www.tensorflow.org/install/pip#windows 并在 venv 上安装了 Tensorflow(它已成功安装)然后我停用了 venv 然后再次加入以检查它是否已安装并且不再存在?

收到这条消息

(venv) C:\Users\eddie>python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
2020-07-20 16:33:41.151220: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2020-07-20 16:33:41.154540: 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.
2020-07-20 16:33:42.469966: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'nvcuda.dll'; dlerror: nvcuda.dll not found
2020-07-20 16:33:42.473332: E tensorflow/stream_executor/cuda/cuda_driver.cc:313] failed call to cuInit: UNKNOWN ERROR (303)
2020-07-20 16:33:42.478266: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: LAPTOP-PV67HTAL
2020-07-20 16:33:42.481952: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: LAPTOP-PV67HTAL
2020-07-20 16:33:42.483927: I tensorflow/core/platform/cpu_feature_guard.cc:143] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2020-07-20 16:33:42.494211: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x29059196c40 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-07-20 16:33:42.499523: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
tf.Tensor(-660.95654, shape=(), dtype=float32)

我注意到他们的安装文档说在我使用完 Tensorflow 之前不要退出 venv,这是否意味着我每次加入同一个 venv 时都需要重新安装它?如果是这种情况,有没有办法保持安装?

对于使用 Tensorflow 的人来说,是否有常规设置?我打算用vscode搭配它,但是这个安装让我很头疼。

【问题讨论】:

    标签: python tensorflow virtualenv


    【解决方案1】:

    不,您不需要每次都重新安装 tensorflow。当您激活虚拟环境时,所有必要的变量都会被设置,并且您可以访问已安装在此环境中的库。

    关于消息:这表明 tf 已安装并且正在运行。尽管有一些关于缺少库的警告,但您在最后一行得到了结果。

    看看你的消息的最后一行:

    tf.Tensor(-660.95654, shape=(), dtype=float32)
    

    这是结果

    import tensorflow as tf
    print(tf.reduce_sum(tf.random.normal([1000, 1000])))
    

    命令。

    【讨论】:

    • 哦!我觉得自己很愚蠢,我花了一个小时试图弄清楚安装,并因为认为它不起作用而感到非常沮丧。非常感谢!
    【解决方案2】:

    不,你不需要每次加入 virtualenv 时都重新安装 Tensor 流

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-18
      • 1970-01-01
      • 1970-01-01
      • 2023-04-09
      • 1970-01-01
      • 2019-12-24
      • 1970-01-01
      • 2021-08-02
      相关资源
      最近更新 更多