Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions packer/scripts/disable-apt-services.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

set -e

function killService() {
service=$1
sudo systemctl stop $service
sudo systemctl kill --kill-who=all $service

# Wait until the status of the service is either exited or killed.
while ! (sudo systemctl status "$service" | grep -q "Active: \(inactive (dead)\)")
do
sleep 10 && echo "Sleeping 10 for $service..."
done
}

function disableTimers() {
sudo systemctl disable apt-daily.timer
sudo systemctl disable apt-daily-upgrade.timer
}

function killServices() {
killService unattended-upgrades.service
killService apt-daily.service
killService apt-daily-upgrade.service
}

function main() {
disableTimers
killServices
}

main
52 changes: 52 additions & 0 deletions packer/scripts/provision-snark-challenge.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash

set -e

sleep 5

#=================================#
# Download Repositories for Dev #
#=================================#

# git clone https://github.com/CodaProtocol/snark-challenge-prover-reference.git
git clone https://github.com/CodaProtocol/cuda-fixnum.git

#=================================#
# Download Dependencies for Dev #
#=================================#
sudo apt-get update -y
sudo apt-get install -y build-essential \
dkms freeglut3 freeglut3-dev libxi-dev libxmu-dev \
cmake \
git \
libgmp3-dev \
libprocps-dev \
python-markdown \
libboost-all-dev \
libssl-dev

sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub

wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.1.168-1_amd64.deb
sudo dpkg -i ./cuda-repo-ubuntu1804_10.1.168-1_amd64.deb
sudo apt-get update
sudo apt-get install cuda-10-1 -y
nvidia-smi -pm 1
# Verify Install
nvidia-smi

# Add Cuda Tools to PATH
touch ~/.bash_profile
echo "PATH=/usr/local/cuda-10.1/bin:$PATH" > ~/.bash_profile

# Cleanup
rm cuda-repo-ubuntu1804_10.1.168-1_amd64.deb

#=================================#
# Set GCC & G++ Versions #
#=================================#
sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa
sudo apt-get update
sudo apt-get install -y gcc-7 g++-7
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 99 --slave /usr/bin/g++ g++ /usr/bin/g++-7

40 changes: 40 additions & 0 deletions packer/templates/snark-challenge-dev.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"variables": {
"aws_access_key": "",
"aws_secret_key": ""
},
"builders": [
{
"type": "amazon-ebs",
"region": "us-west-2",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"source_ami": "ami-0196ce5c34425a906",
"instance_type": "p3.2xlarge",
"ssh_username": "ubuntu",
"ami_name": "coda-snark-challenge-base-{{isotime \"2006-01-02-0304\"}}",
"ami_block_device_mappings": [ {
"device_name": "/dev/sda1",
"volume_size": 50,
"delete_on_termination": true
} ]
}
],
"provisioners": [
{
"type": "shell",
"script": "scripts/disable-apt-services.sh"
},
{
"type": "shell",
"script": "scripts/provision-snark-challenge.sh"
},
{
"type": "shell",
"inline": [
"sudo systemctl enable apt-daily.timer",
"sudo systemctl enable apt-daily-upgrade.timer"
]
}
]
}