每次加入virtualenv时都需要重新安装Tensorflow吗?

时间:2020-07-20 23:41:30

标签: python tensorflow virtualenv

所以我遵循了本教程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与之配合使用,但是此安装让我头疼。

2 个答案:

答案 0 :(得分:2)

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

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

查看邮件的最后一行:

fig, ax = plt.subplots(figsize=(10, 6))

california = merged[merged['STATENAME'] == 'California']

rs = california[california['party'] == 'R']
ds = california[california['party'] == 'D']
# set the value column that will be visualised
variable = 'PCT'
# create map
rs.plot(column=variable, ax=ax, legend=False, cmap='Reds', scheme='quantiles', k=7)
ds.plot(column=variable, ax=ax, legend=True, cmap='Blues', scheme='quantiles', k=7)

这是

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

命令。

答案 1 :(得分:1)

没有,您不需要在每次加入virtualenv时都重新安装Tensor流