Tensorflow Hub : Stuck while importing a model

Viewed 3296

Trying to import some models with Tensorflow Hub with this code :

import tensorflow as tf
import tensorflow_hub as hub

elmo_model = hub.Module('https://tfhub.dev/google/elmo/2', trainable=True)

Makes my notebook stuck. The only log line appearing before getting stuck is :

INFO:tensorflow:Using /tmp/tfhub_modules to cache modules.

How to unstuck it and allow me to import models from Tensorflow Hub ?

1 Answers

It was simply about privileges : I couldn't access the default directory where Tensorflow Hub store the models (/tmp/tfhub_modules).

To solve it, I just choose a directory to store the models which I can access :

import os
import tensorflow as tf
import tensorflow_hub as hub

os.environ['TFHUB_CACHE_DIR'] = '/home/user/workspace/tf_cache'
elmo_model = hub.Module('https://tfhub.dev/google/elmo/2', trainable=True)
Related