Reputation: 21
In the conda environment which was created by me, I try to run tensorflow-hub, it fails when tensorflow try to get write access.
error message:
tensorflow.python.framework.errors_impl.PermissionDeniedError: /tmp/tfhub_modules/96e8f1d3d4d90ce86b2db128249eb8143a91db73.lock.tmp40b1daf1ca7d4f62a23d9457654a995d; Permission denied
error code:
module_url = "https://tfhub.dev/google/universal-sentence-encoder-large/3" embed = hub.Module(module_url)
I know the reason is my py file has no write access, but I don't know how to solve it if I continue want to work in my created conda environment rather than my local machine.
whole error message :
File "/home/ld-sgdev/liuhuo_wan/.conda/envs/tensorflow-hub/lib/python3.7/site-packages/tensorflow_hub/resolver.py", line 379, in atomic_download overwrite=False) File "/home/ld-sgdev/liuhuo_wan/.conda/envs/tensorflow-hub/lib/python3.7/site-packages/tensorflow_hub/tf_utils.py", line 65, in atomic_write_string_to_file f.write(contents) File "/home/ld-sgdev/liuhuo_wan/.conda/envs/tensorflow-hub/lib/python3.7/site-packages/tensorflow/python/lib/io/file_io.py", line 106, in write self._prewrite_check() File "/home/ld-sgdev/liuhuo_wan/.conda/envs/tensorflow-hub/lib/python3.7/site-packages/tensorflow/python/lib/io/file_io.py", line 92, in _prewrite_check compat.as_bytes(self.__name), compat.as_bytes(self.__mode)) tensorflow.python.framework.errors_impl.PermissionDeniedError: /tmp/tfhub_modules/96e8f1d3d4d90ce86b2db128249eb8143a91db73.lock.tmp40b1daf1ca7d4f62a23d9457654a995d; Permission denied
Upvotes: 2
Views: 1860
Reputation: 1071
Encountered the same problem. In my case the following command solves it.
$ export TFHUB_CACHE_DIR=./tmp
I think the root cause is, when you use tf_hub to load something, it uses the default folder (/tmp) to save the downloaded model. In my case, my Tensorflow doesn't have the write access to the default folder.
Upvotes: 5