Skip to content

Instantly share code, notes, and snippets.

@fidothe fidothe/

Last active Jul 26, 2017
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 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:

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
# 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
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
# 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
# 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 | bash
git clone ~/torch --recursive
cd ~/torch; ./
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.