【发布时间】:2020-11-18 06:13:30
【问题描述】:
每次我使用 TensorFlow (CPU) 运行 Python 代码时,例如:
import keras
我看到了:
2020-10-30 15:27:20.518894: 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-10-30 15:27:20.518894: 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-10-30 15:27:23.713077: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'nvcuda.dll'; dlerror: nvcuda.dll not found
2020-10-30 15:27:23.713077: E tensorflow/stream_executor/cuda/cuda_driver.cc:313] failed call to cuInit: UNKNOWN ERROR (303)
2020-10-30 15:27:23.716077: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: User1-PC
2020-10-30 15:27:23.716077: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: User1-PC
2020-10-30 15:27:23.729078: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x10cad0c0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-10-30 15:27:23.729078: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version
Using TensorFlow backend.
如果我把所有的等待时间加起来,大约有 10 秒的等待时间。
有没有办法加快这个过程?特别是如果我使用 TensorFlow 进行推理(而不是训练),我不想每次启动都等待 10 秒引擎。
注意:当然,当我的代码准备好时,我会保持使用 TensorFlow 的进程不断运行,并且我会使用某种进程间通信,以避免重新启动整个程序。
我的问题主要针对 原型设计 阶段,当您经常需要重新启动程序时:原型设计时,每个脚本启动必须等待 10 或 15 秒非常不方便。
【问题讨论】:
-
你能用jupyter用python notebook吗?您说问题出在原型设计中……当我在进行原型设计并希望快速重新编译几行代码或整个类时,使用 jupyter 笔记本非常棒,而且比重新运行文件要快得多。
-
另外,我用于快速测试的另一个技巧是将网络结果缓存到文件的包装器。这样,如果我的测试代码只是使用相同的数据并且我只是在使用其他正在消化网络输出的代码,那么导入语句将被跳过。我已将其用于语言嵌入和图像嵌入提取。最后,我还使用
np.random.rand(...)生成数据来代替运行 tensorflow 以测试所有后神经网络处理。
标签: python tensorflow keras