Why yes, I did used to do PHP development, but what does that have to do with TensorFlow Hub not working on my machine?
[NOTE, added 2020–01–02: This article is written in a jocular tone. It jokingly makes fun of PHP, because of a config change that Valet/Laravel used to make to your DNS. This made some PHP defenders crawl out of the woodwork to be mean to me. I considered taking this article down, because I don’t like conflict, but so many people have found it useful, that doesn’t seem fair.
So instead, a plea: please, if PHP jokes hurt your feelings; don’t read this article! If you do, keep in mind, I am making a joke. PHP is a fine language. I used to do PHP development (see: the title) and I enjoyed it.]
Everyone has skeletons in their closet. Sometimes, one of those skeletons is PHP development. Maybe it was just a fling, maybe it was a long relationship, but thankfully you’ve moved on. You do real computer science-y stuff now, like machine learning. But, for some reason, you can’t get TensorFlow Hub models to download locally. That’s why you’re here.
You’re sad, because
TensorFlow Hub is a library for reusable machine learning modules
and that sounds awesome, and you just want to embed some damn sentences, not average word embeddings like a savage. But you can’t, because when you try it says it can’t connect. Want to confirm that it’s messed up settings on your machine? https://tfhub.dev/ is a website that works:
If you can’t see that page, here’s how to fix your machine.
- Curse PHP in the name of whatever deity speaks to you
- Check
/etc/hosts
and/private/etc/hosts
for.dev
— if you find it, remove that/those line(s) - Check
/usr/local/etc/dnsmasq/conf
- Find a link to a different file,
~/.valet/dnsmasq.conf
, which containsaddress=/.dev/127.0.0.1
- Delete that file
- Run
sudo launchctl stop homebrew.mxcl.dnsmasq
or whatever command stops Dnsmasq on your system
There you go!
Here’s what was going on: Valet/Laravel had mapped .dev to localhost, because .dev wasn’t a valid TLD until recently. Rails also used to do this, so if you were a Rails developer, you may have the same problem, but the fix is going to be slightly different — but step 2 may still work.
Special thanks to Yuriy Golobokov for helping me debug this!