From charlesreid1

The code for Pyrit is here: https://code.google.com/p/pyrit/downloads/list

Building Pyrit on Ubuntu AWS Instance

This guides you through building Pyrit on an AWS machine. AWS machines that are GPU clusters only have Nvidia GPUs.

Getting Set Up

Installing on Ubuntu will require the OpenSSL and Libpcap development libraries (i.e., headers), which aren't on Ubuntu by default:

$ apt-get update
$ apt-get install build-essential python python-dev
$ apt-get install libssl-dev libpcap-dev openssl openssl-dev

Good computer, more pills:

$ apt-get install -y gcc g++ gfortran build-essential git wget linux-image-generic libopenblas-dev python-dev python-pip python-nose python-numpy

Installing Pyrit

Now we're ready to install Pyrit:

$ python setup.py build
$ python setup.py install

Installing Pyrit CUDA

Installing CUDA

Before you can install CPyrit Cuda, you have to install CUDA.

Some instructions here: http://tleyden.github.io/blog/2014/10/25/cuda-6-dot-5-on-aws-gpu-instance-running-ubuntu-14-dot-04/ (outdated)

More instructions here: http://markus.com/install-theano-on-aws/

You have two options:

Dive into the gauntlet of privacy violations required in signing up for an account with Nvidia,

Or use the link from the above blog post to download the CUDA developer package (hint: do this one):

sudo wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_7.0-28_amd64.deb  

Now install it:

$ deb -i cuda-repo-ubuntu1404_7.0-28_amd64.deb
$ apt-get update
$ apt-get install -y cuda  


Build CPyrit Cuda

Now if everything went well you should be able to build CPyrit Cuda:

$ python setup.py build && python setup.py install
running build
running build_ext
Compiling CUDA module using nvcc 7.0, V7.0.27...
Executing '/usr/local/cuda/bin/nvcc -m64 --host-compilation C -Xcompiler "-fPIC" --ptx ./_cpyrit_cudakernel.cu'
nvcc warning : option 'host-compilation' has been deprecated
Building modules...
building 'cpyrit._cpyrit_cuda' extension
creating build
creating build/temp.linux-x86_64-2.7
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/local/cuda/include -I/usr/include/python2.7 -c _cpyrit_cuda.c -o build/temp.linux-x86_64-2.7/_cpyrit_cuda.o -Wall -fno-strict-aliasing -DVERSION="0.4.0"
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/cpyrit
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/_cpyrit_cuda.o -lcrypto -lcuda -lz -o build/lib.linux-x86_64-2.7/cpyrit/_cpyrit_cuda.so
running install
running build
running build_ext
Skipping rebuild of Nvidia CUDA kernel ...
Building modules...
running install_lib
copying build/lib.linux-x86_64-2.7/cpyrit/_cpyrit_cuda.so -> /usr/local/lib/python2.7/dist-packages/cpyrit
running install_egg_info
Writing /usr/local/lib/python2.7/dist-packages/cpyrit_cuda-0.4.0.egg-info

Testing CPyrit Cuda

You can use Cuda built-in tests to make sure your Cuda install went okay. Basically, it looks like this:

$ cd /usr/local/cuda/samples/1_Utilities/deviceQuery
$ make
$ ./deviceQuery

and the result looks like this:

root@ip-172-31-23-0:~/codes/_tarballs# cd /usr/local/cuda/samples/1_Utilities/deviceQuery
root@ip-172-31-23-0:/usr/local/cuda/samples/1_Utilities/deviceQuery# make
/usr/local/cuda-7.0/bin/nvcc -ccbin g++ -I../../common/inc  -m64    -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_52,code=compute_52 -o deviceQuery.o -c deviceQuery.cpp
/usr/local/cuda-7.0/bin/nvcc -ccbin g++   -m64      -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_52,code=compute_52 -o deviceQuery deviceQuery.o 
mkdir -p ../../bin/x86_64/linux/release
cp deviceQuery ../../bin/x86_64/linux/release
root@ip-172-31-23-0:/usr/local/cuda/samples/1_Utilities/deviceQuery# ./deviceQuery 
./deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

modprobe: ERROR: could not insert 'nvidia_346': Unknown symbol in module, or unknown parameter (see dmesg)
cudaGetDeviceCount returned 38
-> no CUDA-capable device is detected
Result = FAIL

Reboot

$ reboot

which did nothing, issue was still there when I ran any CUDA test.

More Pills

OK computer more pills:

$ apt-get install linux-image-extra-virtual
$ reboot

Load Nvidia Kernel Module Explicitly

What happens if we explcitly reload the Nvidia kernel module?

$ modprobe nvidia
modprobe: ERROR: ../libkmod/libkmod-module.c:809 kmod_module_insert_module() could not find module by name='nvidia_346'
modprobe: ERROR: could not insert 'nvidia_346': Function not implemented

Double Check

Double check to make sure there aren't conflicting drivers. Nope, nvidia installer added nouveau to the blacklist to avoid potential driver conflicts.

Tried running this:

$ update-initramfs -u

Then a reboot.


WTF

root@ip-172-31-23-0:/home/ubuntu# modprobe nvidia
modprobe: ERROR: ../libkmod/libkmod-module.c:809 kmod_module_insert_module() could not find module by name='nvidia_346'
modprobe: ERROR: could not insert 'nvidia_346': Function not implemented
root@ip-172-31-23-0:/home/ubuntu# apt-get install nvidia-346
Reading package lists... Done
Building dependency tree       
Reading state information... Done
nvidia-346 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 85 not upgraded.

One Last Try

$ apt-get install linux-source
$ apt-get install linux-headers-generic
Examining /etc/kernel/header_postinst.d.
run-parts: executing /etc/kernel/header_postinst.d/dkms 3.13.0-61-generic /boot/vmlinuz-3.13.0-61-generic
Error! Bad return status for module build on kernel: 3.13.0-61-generic (x86_64)
Consult /var/lib/dkms/nvidia-346/346.46/build/make.log for more information.