Ubuntu 上的 Tensorflowhub 负载问题

Issue with Tensorflowhub load on Ubuntu

我正在 Windows 和 Ubuntu 以及 运行 上做一些基于 Tenaordlow Hub 的事情,以解决 Ubuntu 上的问题。所以我做了 hub.load("https://tfhub.dev/google/universal-sentence-encoder/4")

问题出在 Ubuntu,每次重新启动计算机时它都会重新下载整个内容,但在 Windows 我没有这样的问题,它会在几秒钟内加载而无需下载。我如何确保它也将下载的存储在 Ubuntu 上?

here 所述,库在 os.path.join(tempfile.gettempdir(), "tfhub_modules") 缓存下载,在 Linux 评估为 /tmp/tfhub_modules。如果您想在多次重启后保留缓存模型,请添加例如export TFHUB_CACHE_DIR=$HOME/.cache/tfhub_modules 到您的 .bashrc 文件以将缓存目录更改为持久目录。