hashcat / hashcat

World's fastest and most advanced password recovery utility
https://hashcat.net/hashcat/
21.45k stars 2.93k forks source link

Metal backend doesn't work on supported GPU #3438

Closed VadimMuhtarov closed 2 years ago

VadimMuhtarov commented 2 years ago

I get clCompileProgram(): CL_BUILD_PROGRAM_FAILURE with default settings and No devices found/left. with --backend-ignore-opencl flag when trying to run the benchmark. Also I tried all combinations with -D and -d, used --force flag, recompiled Hashcat from sources, nothing helped.

hashcat -I
hashcat (v6.2.6) starting in backend information mode

Metal Info:
===========

Metal.Version.: 212.8

Backend Device ID #1
  Type...........: GPU
  Vendor.ID......: 2
  Vendor.........: Apple
  Name...........: Intel HD Graphics 4000
  Processor(s)...: 1
  Clock..........: N/A
  Memory.Total...: 1536 MB (limited to 576 MB allocatable in one block)
  Memory.Free....: 704 MB
  Local.Memory...: 32 KB
  Phys.Location..: built-in
  Feature.Set....: macOS GPU Family 1 v4
  Registry.ID....: 1024
  Max.TX.Rate....: N/A
  GPU.Properties.: headless 0, low-power 1, removable 0

OpenCL Info:
============

OpenCL Platform ID #1
  Vendor..: Apple
  Name....: Apple
  Version.: OpenCL 1.2 (Apr 19 2022 00:27:55)

  Backend Device ID #2
    Type...........: CPU
    Vendor.ID......: 8
    Vendor.........: Intel
    Name...........: Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
    Version........: OpenCL 1.2 
    Processor(s)...: 4
    Clock..........: 2500
    Memory.Total...: 8192 MB (limited to 1024 MB allocatable in one block)
    Memory.Free....: 4064 MB
    Local.Memory...: 32 KB
    OpenCL.Version.: OpenCL C 1.2 
    Driver.Version.: 1.1

  Backend Device ID #3
    Type...........: GPU
    Vendor.ID......: 8
    Vendor.........: Intel
    Name...........: HD Graphics 4000
    Version........: OpenCL 1.2 
    Processor(s)...: 16
    Clock..........: 1100
    Memory.Total...: 1536 MB (limited to 192 MB allocatable in one block)
    Memory.Free....: 704 MB
    Local.Memory...: 64 KB
    OpenCL.Version.: OpenCL C 1.2 
    Driver.Version.: 1.2(Jun 21 2022 21:30:14)

hashcat v6.2.6 macOS Catalina 10.15.7 MBP mid 2012

emwinkler commented 2 years ago

Looks like Metal has only been enabled for Apple silicon with its multiple processors. If you want to enable it on any Metal supported GPU, you need to edit this line in src/backend.c

// check if we need skip device

if (device_param->device_processors == 1) device_param->skipped = true;

and change it to:

if (device_param->device_processors == 1) device_param->skipped = false;

Here is what I get on my Intel macbook pro with this change:

hashcat -b --backend-ignore-opencl hashcat (v6.2.6) starting in benchmark mode

Benchmarking uses hand-optimized kernel code by default. You can use it in your cracking session by setting the -O option. Note: Using optimized kernel code limits the maximum supported password length. To disable the optimized kernel code in benchmark mode, use the -w option.

METAL API (Metal 263.8)

Benchmark relevant options:


Speed.#1.........: 413.6 MH/s (79.42ms) @ Accel:2048 Loops:512 Thr:32 Vec:1


Speed.#1.........: 145.0 MH/s (55.78ms) @ Accel:256 Loops:256 Thr:128 Vec:1


Speed.#1.........: 61307.4 kH/s (66.80ms) @ Accel:1024 Loops:256 Thr:16 Vec:1


Speed.#1.........: 16102.9 kH/s (63.41ms) @ Accel:2048 Loops:64 Thr:8 Vec:1


Speed.#1.........: 6763 H/s (74.02ms) @ Accel:64 Loops:256 Thr:128 Vec:1


Speed.#1.........: 652.8 MH/s (47.69ms) @ Accel:2048 Loops:512 Thr:32 Vec:1


Speed.#1.........: 320.0 MH/s (83.89ms) @ Accel:256 Loops:1024 Thr:128 Vec:1


Speed.#1.........: 413.4 MH/s (78.42ms) @ Accel:2048 Loops:512 Thr:32 Vec:1


Speed.#1.........: 31332.5 kH/s (64.28ms) @ Accel:256 Loops:64 Thr:128 Vec:1

VadimMuhtarov commented 2 years ago

Now it works on my new M2 Mac. I think we can close it.