Skip to content

Instantly share code, notes, and snippets.

@fidothe fidothe/README.md
Last active Jul 26, 2017

Embed
What would you like to do?
How to build Torch with CUDA extensions with a Ubuntu 14.04 g2.* instance on EC2

I got Torch + CUDA working on a Ubuntu 14.04 g2.2xlarge EC2 instance using these instructions. Get the latest CUDA install package by consulting https://developer.nvidia.com/cuda-downloads#linux and grabbing the most recent. (7.0 at time of writing).

I also made a public AMI with this, plus Dan Hon's char-rnn fork pre-installed.

It's ami-9bcadbab, or dreaming-prose-public, in the us-west-2 (Oregon) region. You should be able to copy it to another region if you need to. You can launch an instance in the EC2 console at this URL: https://us-west-2.console.aws.amazon.com/ec2/v2/home?region=us-west-2#LaunchInstanceWizard:ami=ami-9bcadbab

You'll need a g2.2xlarge or g2.8xlarge instance or there'll be no CUDA for you...

# It's a Ubuntu 14.04 cloud instance, so you'll be able to log in without a password
# using the keypair you specified at instance creation time and the ubuntu user, eg:
ssh -i /path/to/your/keypair.pem ubuntu@my-instance.us-west-2.compute.amazonaws.com
# make sure your system is up to date
sudo apt-get update
sudo apt-get upgrade
# you need the drm.ko kernel extension, which isn't enabled by default on 14.04 server
sudo apt-get install linux-generic
# get the nvidia package which adds their APT repo
curl -L -O http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_7.0-28_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1404_7.0-28_amd64.deb
sudo apt-get update
# now you get to install CUDA and the nvidia drivers
sudo apt-get install cuda
# CUDA stuff (this assumes you're using the 7.0 link above - modify per the instructions from
# nvidia for newer versions)
cat << EOD >> .bashrc
export PATH=/usr/local/cuda-7.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-7.0/lib64:$LD_LIBRARY_PATH
EOD
# important - need to get the new kernel + nvidia driver loaded
sudo reboot
# verify that driver installed by checking that this next command actually returns some info
cat /proc/driver/nvidia/version
# install torch, per http://torch.ch/docs/getting-started.html
# I kind of hate this approach, the 'trust this random script off the internet':
# you should read the script before you run it...
curl -s https://raw.githubusercontent.com/torch/ezinstall/master/install-deps | bash
git clone https://github.com/torch/distro.git ~/torch --recursive
cd ~/torch; ./install.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.