如何为 Pyrit 编译 OpenCL 模块?

如何为 Pyrit 编译 OpenCL 模块?

我想将我的 GPU 与 Pyrit 一起使用。我使用 Ubuntu 11.10、ATI Radeon HD 68xx 和 i7 2600K。

步骤完成:

  • 从制造商网站安装最新的 ATI 驱动程序
  • 安装 AMD APP SDK

当我运行基准测试时,我得到:

~$ pyrit benchmark
Pyrit 0.4.0 (C) 2008-2011 Lukas Lueg http://pyrit.googlecode.com
This code is distributed under the GNU General Public License v3+

Running benchmark (5037.4 PMKs/s)... - 

Computed 5037.45 PMKs/s total.
#1: 'CPU-Core (SSE2)': 667.8 PMKs/s (RTT 3.2)
#2: 'CPU-Core (SSE2)': 661.6 PMKs/s (RTT 3.2)
#3: 'CPU-Core (SSE2)': 664.0 PMKs/s (RTT 3.2)
#4: 'CPU-Core (SSE2)': 660.5 PMKs/s (RTT 3.2)
#5: 'CPU-Core (SSE2)': 669.7 PMKs/s (RTT 3.2)
#6: 'CPU-Core (SSE2)': 656.3 PMKs/s (RTT 3.2)
#7: 'CPU-Core (SSE2)': 667.4 PMKs/s (RTT 3.2)
#8: 'CPU-Core (SSE2)': 662.6 PMKs/s (RTT 3.1)
  • 如何确保 AMD APP SDK 已正确安装?

  • 如何配置 Pyrit 以使用 OpenCL 和我的 GPU?

编辑:

卸载 Pyrit 并重新安装 AMD APP SDK。尝试为 Pyrit 编译 OpenCL 支持模块时出现此错误:

$ sudo python setup.py build 
The headers required to build the OpenCL-kernel were not found. Trying to continue anyway...
svn: '.' is not a working copy
running build
running build_ext
Building modules...
building 'cpyrit._cpyrit_opencl' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c _cpyrit_opencl.c -o build/temp.linux-x86_64-2.7/_cpyrit_opencl.o -DVERSION="0.3.0"
_cpyrit_opencl.c:23:19: fatal error: CL/cl.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1

答案1

这是我最终在 Ubuntu Server 11.04 上完成的方法

安装最小的 X11 环境:

aptitude install xserver-xorg xserver-xorg-core xserver-xorg-input-evdev xserver-xorg-video-ati lightdm unity-greeter openbox

然后,编辑 /etc/lightdm/lightdm.conf 并添加以下内容(将 YOUR_USER_NAME 替换为您将以之运行 hashcat 的用户):

[SeatDefaults]
greeter-session=unity-greeter
user-session=openbox
autologin-user=YOUR_USER_NAME
autologin-user-timeout=0

然后将您的用户名添加到 nopasswdlogin 组:

usermod -a -G nopasswdlogin $USERNAME

获取 Catalyst 的构建依赖项:

aptitude build-dep fglrx

下载并安装 Catalyst 12.8:

wget http://www2.ati.com/drivers/linux/amd-driver-installer-12-8-x86.x86_64.zip
unzip amd-driver-installer-12-8-x86.x86_64.zip
sh amd-driver-installer-8.982-x86.x86_64.run --uninstall=force
sh amd-driver-installer-8.982-x86.x86_64.run

生成新的 xorg.conf:

rm -f /etc/X11/xorg.conf*
amdconfig --adapter=all --initial

确保 DISPLAY 环境变量已设置:

echo 'export DISPLAY=:0' >>~/.bashrc

重新启动,一切就绪。

答案2

我从未使用过 Pyrit 或尝试过编译,但似乎它的配置脚本 (setup.py) 找不到 OpenCL 头文件。您应该查看此类脚本中配置所需的路径。ATI VGA 的 OpenCL 头文件可能安装在驱动程序安装的某个子文件夹中。

编辑:

这是此脚本的一部分,用于设置 OpenCL.h 路径。在您的 PC 上找到此文件,然后进行一些实验,选择其中之一,然后尝试更改它,看看是否有效。

OPENCL_INC_DIRS = []
OPENCL_LIB_DIRS = []
EXTRA_LINK_ARGS = []
LIBRARIES = ['crypto', 'z']
if sys.platform == 'darwin':
    # Use the built-in framework on MacOS
    EXTRA_LINK_ARGS.extend(('-framework', 'OpenCL'))
    OPENCL_INC_DIRS.append('/System/Library/Frameworks/OpenCL.framework/Headers')
else:
    LIBRARIES.append('OpenCL')
    try:
        if os.path.exists(os.environ['ATISTREAMSDKROOT']):
            OPENCL_INC_DIRS.append(os.path.join(os.environ['ATISTREAMSDKROOT'], 'include'))
            for path in ('lib/x86_64','lib/x86'):
                if os.path.exists(os.path.join(os.environ['ATISTREAMSDKROOT'], path)):
                    OPENCL_LIB_DIRS.append(os.path.join(os.environ['ATISTREAMSDKROOT'], path))
                    break
    except:
        pass
    for path in ('/usr/local/opencl/OpenCL/common/inc', \
                '/opt/opencl/OpenCL/common/inc', \
                '/usr/local/opencl/include', \
                '/usr/local/cuda/include'):
        if os.path.exists(path):
            OPENCL_INC_DIRS.append(path)
            break
    else:
        print >>sys.stderr, "The headers required to build the OpenCL-kernel " \
                            "were not found. Trying to continue anyway..."

# Get exact version-string from svn
try:
    svn_info = subprocess.Popen(('svn', 'info'), \
                                stdout=subprocess.PIPE).stdout.read()
    VERSION += ' (svn r%i)' % \
                int(re.compile('Revision: ([0-9]*)').findall(svn_info)[0])
except:
    pass

相关内容