Starting Machine Learning with Fast.ai

Getting my system set up to be able to dive into the world of Machine Learning

Jared Daines

4 minute read

Starting fast.ai ’s deep learning course

So recently I came across a really exciting site for me fast.ai. I’ve looked at deep learning courses in the past and have been a bit overwhelmed by the amount of Math that I need to have. However, they take the approach of if you know how to code you can learn to create deep learning programs.

They approach things with the philosophy that you don’t learn all the theory behind music before teaching a child how to play an instrument. Deep learning can be taught the same way. They are trying to make deep learning uncool. To learn more about their philosophy visit their about page.

So tonight is all about seeing if I can get their code working on my laptop. I don’t want to spend the money on an AWS instance. I have a gaming laptop with a Geforce GTX 870M card running Ubuntu 16.10. I will be documenting after this my attempts to get things working on this laptop.

I’m following their install directions for AWS but trying to get it to work on my laptop. Their install directions are here

Below are the steps I’m following

  • Installing the Cuda drivers (I’m betting this will be the hard part)

Getting the Cuda drivers from https://developer.nvidia.com/cuda-downloads they don’t currently have drivers for 16.10 so will be trying the 16.04 drivers to see if those work.

Just waiting on the download for this to finish its a pretty big file at 1.6gb

It seems to have installed correctly. Rebooting and will find out. Going through th Quick Start Guide to verify that its working as expected.

Rebooted the computer but it dosen’t look like its working. So I did some googling, and it looks like I now need to install the packages through apt. (This Blog Post had some better instructions)[http://www.pradeepadiga.me/blog/2017/03/22/installing-cuda-toolkit-8-0-on-ubuntu-16-04/] I ended up running this command first though: apt-get install nvidia-cuda-toolkit.

As a side note while waiting for things to install this is a good Ted Talk to Watch

It looks like everything installed here correctly now. However a few things. I wasn’t able to find the path the following referenced path /usr/local/cuda-8.0/bin

So when running the command nvidia-smi I don’t think I’ve quite got the Nvidia drivers set up properly. Doing some digging here. Tried switching the Nvidia drivers but that seems to have broken things so reverting to the original driver this required a couple of restarts.

That didn’t change anything, however, this may not be a big deal This Forum post States it may just be my graphics card. Will do some tests here to see.

  • Installing anaconda

https://www.continuum.io/downloads#linux

I did have anaconda add the path to the bashrc file. However, I’m using oh-my-zhs as my shell. So just copied what was put into the bashrc file into the zshrc file.

This should allow me to run the anaconda command from anywhere in my terminal.

  • Setting things up based on their config files

So they have a couple of files that they have you run on the AWS instances these files can be found at the github repo looking through their bash scripts looks just need to worry about the installs done in install-gpu.sh

   conda install -y bcolz
  conda upgrade -y --all
  pip install theano
  echo "[global] device = gpu floatX = float32 [cuda] root = /usr/local/cuda" > ~/.theanorc
  pip install keras==1.2.2
  mkdir ~/.keras
   echo '{
    "image_dim_ordering": "th",
    "epsilon": 1e-07,
    "floatx": "float32",
    "backend": "theano"
    }' > ~/.keras/keras.json
    ```
  ```bash
  wget "http://files.fast.ai/files/cudnn.tgz" -O "cudnn.tgz"

So this process made me realise I didn’t have the correct cuda files on my computer. So Went back and the initial install of the cuda file from Nvidia didn’t work. Reinstalled that and then did an apt-get update and then apt-get install cuda this gave me the folders in /usr/local/cuda that I was missing

  tar -zxf cudnn.tgz`
  cd cuda
  sudo cp lib64/* /usr/local/cuda/lib64/
  sudo cp include/* /usr/local/cuda/include/
  jupyter notebook --generate-config
  jupass=`python -c "from notebook.auth import passwd; print(passwd())"`
  echo "c.NotebookApp.password = u'"$jupass"'" >> $HOME/.jupyter/jupyter_notebook_config.py
  echo "c.NotebookApp.ip = '*'
  c.NotebookApp.open_browser = False" >> $HOME/.jupyter/jupyter_notebook_config.py
  # clone the fast.ai course repo and prompt to start notebook
  cd ~
  git clone https://github.com/fastai/courses.git
  echo "\"jupyter notebook"\" will start Jupyter on port 8888"
  echo "If you get an error instead, try restarting your session so your $PATH is updated"

Its almost there I think. Just can’t get the cuda to show up in the Jupyter notebooks To test things. I’m calling it a night and will pick it up later.

comments powered by Disqus