To extract training data mkdir train && mv ILSVRC2012_img_train.tar train/ && cd train
tar -xvf ILSVRC2012_img_train.tar && rm -f ILSVRC2012_img_train.tar
find . -name "*.tar" | while read NAME ; do mkdir -p "${NAME%.tar}"; tar -xvf "${NAME}" -C "${NAME%.tar}"; rm -f "${NAME}"; done
// Make sure to check the completeness of the decompression, you should have 1,281,167 images in train folder
To extract validation data
cd ../ && mkdir val && mv ILSVRC2012_img_val.tar val/ && cd val && tar -xvf ILSVRC2012_img_val.tar
Step4: preprocess ImageNet data
This step requires that you have built the caffe project (either the OpenCL caffe or original caffe in CPU_ONLY mode), because we are going to use some of the scripting tools provided by caffe.
cd data/ilsvrc2012
./get_ilsvrc.sh
cd ../../
vi /example/imagenet/create_imagenet.sh
modify the following variables to point to your ImageNet data dir
TRAIN_DATA_ROOT=/hdd/ImageNet/train
VAL_DATA_ROOT=/hdd/ImageNet/val
then set data resize bool to true:
RESIZE=true
then you are ready to create the lmdb format of ImageNet data, as needed by the trianing! ./examples/imagenet/create_imagenet.sh
By the end of this tutorial, you will have successfully installed CUDA 7 and cuDNNv2 working with Caffe on AWS using a g2.2xlarge or g2.8xlarge instance using Ubuntu 14.04.
This guide was tested in May 2015.
Keywords: AWS, GPU, amazon, caffe, install, how, to
Begin Tutorial
This guide also applies to standard desktop Ubuntu installations.
Start up one of Amazon GPU instances (g2.2xlarge or g2.8xlarge) using Ubuntu 64 bit (HVM) andNOT Amazon's AMI. Make sure to attach both instance store 0 and instance store 1 in the "Add Storage" step. Also increase the Root /dev/sda1 device size to something larger than 8 GiB.
Note: Amazon says you must use the 340.46 driver (see the official GPU documentation here) but this guide works while using the most recent NVIDIA driver 346.46.
Download the "run" CUDA installer (which includes the NVIDIA driver) from NVIDIA's website. The link is usually here.
Then update the linux image to be compatible with NVIDIA's drivers:
sudo apt-get install linux-image-extra-virtual
Important: While installing the linux-image-extra-virtual, you may be prompted "What would you like to do about menu.lst?" I selected "keep the local version currently installed"
We now need to disable nouveau since it conflicts with NVIDIA's kernel module:
sudo vi /etc/modprobe.d/blacklist-nouveau.conf
And add the following lines to this file:
blacklist nouveau
blacklist lbm-nouveau
options nouveau modeset=0
alias nouveau off
alias lbm-nouveau off
Back in the terminal/shell, execute the commands:
echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf
sudo update-initramfs -u
sudo reboot
After the reboot is complete, we have a few more steps:
You may get errors for create_mnist.sh but run train_lenet.sh anyway. Chances are it will still work. If you see the network training, then everything has been successfully set up.
If you want to use Python wrapper for caffe, then you should add path to the PYTHONPATH variable:
export PYTHONPATH=/home/username/caffe/python
I got an error "Failed to initialize libdc1394" when I tried to import caffe. Actually, libdc1394 is a library for controlling camera hardware, so we can disable it: