TF, Python, Virtualenv, Disk Space

With a newly upgraded Debian dist (to Stretch – yes, I have one more to go!) I began testing how the environment looks. Couple things which I think are different:

  • Jupyter – I guess this is expected to be run from a virtual-env? I don’t recall that. But all the usage links online suggest that as the way to go.
  • Virtualenv. More generally I went down the rabbit hole of trying to figure out the implications of pip, virtualenv and apt-get-installed python. A few links, taking care to try and figure out which ones are out-of -date and gleaning what’s common. Seems like the way to go is to
    1. Have a distribution-based python enviro  (i.e. with apt-get).
    2. sudo -H pip3 install –upgrade pip
    3. sudo -H pip3 install virtualenv
    4. Now rely on virtualenvs.
  • I’m still a little murky on the -H which ties the environment to a user home directory. Also, at least one link (was good but a bit dated) suggested using
    • pip install –user
  • This would install things in a directory ‘/home/steve/.local/…’. It’s kind of unclear what benefit this brings other than having a local ‘base’ python from which to extend pip with “virtualenv –system-site-packages”
  • For now, I’m just going vanilla virtualenv

Now having happily done this, I look to start up a virtualenv and add tensorflow.

Issues:

  1. Install of tensorflow with pip3 crashes with space full. Admittedly I have a small drive (75 Gb) but I know that earlier this year I had TF installed. Well, I thought maybe it’s time to bite the bullet and clone my drive to my 1 Tb drive I’ve had around for this purpose. Spent some time trying to review how I cloned a drive recently on my Flint machine. Slept, thought about it over breakfast and instead decided to proceed as follows:
    1. Figure out exactly where and why disk space was dying (suspicion was root partition). If not curable, then:
    2. Use Gparted Live usb drive to see if I can manipulate unused space to get big enough to work. If not curable there, then:
    3. Mount new drive, use dd to clone original to bigger drive, update-grub on new drive from gparted live (I think), and reboot, hoping I don’t have to do the manual edit of grub.cfg and /etc/fstab which I needed to do with Flint.
  2. Well it turns out that the issue was just TMPDIR. I could install just fine by:
  3. TMPDIR=… pip3 install -vvv tensorflow
  4. Then next issue: start up python and import tensorflow core-dumps with illegal instruction. Some well written posts (on github, bookmarked) show via good detectivework that since TF 1.6, binaries have been compiled with CPU optimizations that assume something called ‘AVX’ capability which ‘older’ CPUs won’t support. Solution is to compile from source or use tensorflow==1.5
  5. I’d like to try the compile from source so that will be my next effort. This exercise has me thinking about giving a gpu a try. But should I do the source compile first or up my disk space?

Postscript:

Playing with it a bit more, it looks like I have a site-installed version of TensorFlow (v1.3) for python2.7. So maybe my memory failed in recalling that I had been working primarily with python 2. It’s only at work that I’ve fully embraded python3 and I’m sure I just confused myself. So if I create and start up a virtualenv with site-packages then I get the site-installed version of TensorFlow for python2.

 

Leave a comment