如何在kali linux中安装英伟达内核模块cuda和pyrit

2020-11-02 教育 159阅读
安装cuda以及nvidia驱动
这一步比较简单,安装之前,推荐大家编辑一下/etc/apt/source.list文件,把国外的源注释掉换成国内科大的,下载比较快。科大源的地址如下
deb http://mirrors.ustc.edu.cn/kali kali main non-free contrib
deb-src http://mirrors.ustc.edu.cn/kali kali main non-free contrib
deb http://mirrors.ustc.edu.cn/kali-security kali/updates main contrib non-free
设置完之后,执行以下命令安装
apt-get update
apt-get install nvidia-detect nvidia-libopencl1 nvidia-opencl-common nvidia-support nvidia-opencl-icd nvidia-visual-profiler nvidia-glx nvidia-installer-cleanup nvidia-kernel-common nvidia-smi nvidia-alternative nvidia-opencl-dev libglx-nvidia-alternatives nvidia-kernel-dkms nvidia-cuda-toolkit nvidia-vdpau-driver nvidia-xconfig glx-alternative-nvidia libgl1-nvidia-alternatives nvidia-settings libgl1-nvidia-glx xserver-xorg-video-nvidia libcublas4 libcudart4 libcufft4 libnpp4 libnvidia-compiler libcuda1 libcuinj4 libnvidia-ml1 libxvmcnvidia1 libcusparse4 libcurand4 python-pycuda-doc python-pycuda-headers python-pycuda nvidia-cuda-doc nvidia-cuda-gdb
由于包比较多可能有点慢,安装过程会弹出两个窗口需要确认,直接OK就好,执行完之后toolkit和驱动都装上了,然后把一些变量写入系统,在/root/.bashrc最后面加上下面一段
PATH=$PATH:/usr/lib/nvidia-cuda-toolkit/bin
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/nvidia-cuda-toolkit/lib:/lib
export PATH
export LD_LIBRARY_PATH
可以执行一下ldconfig马上生效,不过反正都要重启一次的了,重启。
安装pyrit-cuda
下面重新编译个pyrit来试一试使用GPU。下载pyrit的地址是:
https://code.google.com/p/pyrit/downloads/list
我们需要下载pyrit-0.4.0.tar.gz和cpyrit-cuda-0.4.0.tar.gz,下载完之后,安装一下编译所需要的工具
atp-get install libpcap-dev python2.7-dev
解压pyrit-0.4.0.tar.gz并且安装
tar -xzvf pyrit-0.4.0.tar.gz
cd pyrit-0.4.0
python setup.py build
python setup.py install
解压cpyrit-cuda-0.4.0.tar.gz
tar -xzvf cpyrit-cuda-0.4.0.tar.gz
cd cpyrit-cuda-0.4.0
这里需要进行一些改动,编辑setup.py,把第35行
for path in ('/usr/local/cuda', '/opt/cuda'):
改成
for path in ('/usr/local/cuda','/usr/lib/nvidia-cuda-toolkit','/opt/cuda'):
免得安装程序找不到nvcc
然后就安装
python setup.py build
python setup.py install
安装完,运行一下
pyrit list_cores
应该能看到GPU了,类似
#1: 'CUDA-Device #1 'GeForce 8400 GS''
#2: 'CPU-Core (SSE2)'
#3: 'CPU-Core (SSE2)'
#4: 'CPU-Core (SSE2)'
#5: 'CPU-Core (SSE2)'
#6: 'CPU-Core (SSE2)'
#7: 'CPU-Core (SSE2)'
#8: 'CPU-Core (SSE2)'
安装optimus
把源Key取回来
wget -O - http://suwako.nomanga.net/suwako.asc | apt-key add -
在/etc/apt/source.list中加入Bumblebee的源
deb http://suwako.nomanga.net/debian sid main contrib
deb-src http://suwako.nomanga.net/debian sid main
然后执行安装
apt-get update
apt-get install bumblebee bumblebee-nvidia
安装完毕,把root加入bemblebe组,然后重启
adduser root bumblebee
重启完毕可以测试一下,分别运行
glxspheres
optirun glxspheres
可以看到帧数是不同的
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com