Thursday, July 13, 2017

Macbook Pro Setup for fast.ai MOOC

Background

I decided I wanted to run the exercises from the fast.ai MOOC on my local computer. The recommended approach is to run everything on a t2 AWS instance to make sure everything is setup correctly and then run the final product on a p2 AWS instance. While it still makes sense to run your final job on something with a lot of GPU horsepower (like an AWS p2 instance or Floydhub), I didn't particularly feel like using an AWS instance with no GPU to setup the job. Thus the quest for setting up my home machine - a Macbook Pro running MacOS Sierra with a NVIDIA GeForce GT 750M 2048 MB card - for this purpose. 

The process

  1. Install xcode 8.2 command line tools from apple’s site from here: http://adcdownload.apple.com/Developer_Tools/Command_Line_Tools_macOS_10.12_for_Xcode_8.2/Command_Line_Tools_macOS_10.12_for_Xcode_8.2.dmg. (Note: as of this writing, CUDA 8.0 requires Xcode 8.2 on Mac OS Sierra Other versions of Xcode lead to a nvcc error - nvcc is the nvidia compiler)
  2. Make the Xcode command line tools the default: sudo xcode-select --switch /Library/Developer/CommandLineTools/
  3. Install CUDA 8.0 from here: https://developer.nvidia.com/cuda-downloads. Make sure you check if your particular graphics card is supported. There's a support matrix on the CUDA site.
  4. Install cuDNN 5.1 for CUDA 8.0 (https://developer.nvidia.com/compute/machine-learning/cudnn/secure/v5.1/prod_20161129/8.0/cudnn-8.0-osx-x64-v5.1-tgz). (Note: although higher versions of cuDNN are available, keras 1.2.2 seems to only work with cuDNN 5.x)
  5. Install anaconda using the anaconda installer from https://www.continuum.io/downloads,
  6. Install theano (pip install theano)
  7. Install keras v1.2.2 (pip install keras==1.2.2)
  8. Install kaggle-cli

Caveats

The list above is from memory and judicious use of the bash history command, so I cannot guarantee I haven't missed anything. If you happen to get stuck at some point, try looking at the script here http://files.fast.ai/files/install-gpu.sh to figure out if you can spot the missing piece. The steps below are based off that script.

1 comment:

Meandering Thoughts said...

Thank you for the post!

Helped me setup my MBP for the course.
Although significantly slower than AWS p2.
At least its workable.

Only thing that I found that need to be fixed is ~/.keras/keras.json file.
From tn/tensorflow to th/theano


{
"image_dim_ordering": "th",
"epsilon": 1e-07,
"floatx": "float32",
"backend": "theano"
}