BitCrack icon indicating copy to clipboard operation
BitCrack copied to clipboard

[HELP] "Out of Memory" error after distributing tasks (CUDA memory cleanup)

Open joaoescribano opened this issue 1 month ago • 1 comments

Hello, First of all, thank you for all the hard work. I'm not a C++ dev by trade, but I've been experimenting with BitCrack to create a pool-like setup for distributing work. Here's what I'm trying to achieve:

  1. Objective

    • Modify BitCrack to connect to my custom socket server (like a pool).
    • Distribute tasks such as Puzzle 67 or random wallet searches.
    • Upon completion of a task, the worker requests a new one without restarting BitCrack.
  2. What I’ve done so far

    • Edited KeyFinder.cpp to connect to my socket server using flags like:
      --pool 127.0.0.1 --user admin --pass 123 --worker bob --puzzle 67
      
    • Once connected, the server distributes the required parameters (keyspace, target, compression, etc.).
    • After finishing a task, BitCrack sends a new “job request” to the server.
  3. The issue

    • After successfully completing the first task, BitCrack attempts to request a second job.
    • Suddenly, I get this error message:
      terminate called after throwing an instance of 'KeySearchException'
      
    • Digging deeper, I found the CUDA error message:
      cudaErrorMemoryAllocation: Out of memory
      
  4. Hypothesis

    • It seems the CUDA memory isn't being cleaned up properly after the first task completes.
    • On the second task request, the GPU memory still allocated and not properly freed (almost 40% still in use), leading to an out-of-memory error.
  5. Request for Help

    • Could someone point me to where in the BitCrack codebase I could implement a proper CUDA memory cleanup routine after each cycle?
    • Is there a recommended pattern or function call I should be using in C++/CUDA to ensure the device memory is freed before requesting a new task?
  6. Additional Info

    • Environment:
      • OS: Ubuntu 24.04
      • Compiler: g++ (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
      • CUDA Version: 12
      • GPU Model: RTX 3080 TI
    • I’m open to any best practices, suggestions, or code snippets that might help handle the memory cleanup gracefully.

Thank you in advance for any help you can provide. Please let me know if there's any additional information I can provide.

joaoescribano avatar Jan 02 '25 03:01 joaoescribano