Setup cache folder for tensorflow build

Is there anyway to specify the cache folder for TF build, so that I don’t have to rebuilt everytime after the computer is rebooted?

I tried to set the TMP folder, but it does not help.

 TMP=~/tmp bazel build //tensorflow/tools/pip_package:build_pip_package

This seems does not work, the ~/tmp folder is empty all the time.

The default is ~/.cache/bazel so it is available after reboot.

You can add an extra cache with:

https://docs.bazel.build/versions/main/remote-caching.html#disk-cache

But you need to consider also the cache invalidation effect of large regular changes like this one:

https://tensorflow-prod.ospodiscourse.com/t/llvm-updates-and-bazel-cache/2060?u=bhack

More in general you could be interested in: