GPU-support in Sand-Bob

GPU-support in Sand-Bob#

Sand-Bob has a flag to enable GPU-support within the docker containers executing our code.

from sand_bob import generate_code, config_scadsai_llm

config_scadsai_llm()
result = generate_code("use cupy to print out the name of the GPU", 
              dependencies=["cupy"],
              n_codefix_attempts=1,
              n_feedback_iterations=0,
              gpu_support=True, # this is required to give the docker container access to the GPU
              final_touch=False
             )
result

Execution Output

GPU name (detected by CuPy):
NVIDIA GeForce RTX 3050 Ti Laptop GPU
import cupy as cp

# Get the current device ID
device_id = cp.cuda.Device().id

# Retrieve device properties (includes the GPU name)
props = cp.cuda.runtime.getDeviceProperties(device_id)

# The 'name' field may be bytes; decode if needed
gpu_name = props["name"]
if isinstance(gpu_name, bytes):
    gpu_name = gpu_name.decode()

# Second‑last print: description
print("GPU name (detected by CuPy):")

# Last print: the result only
print(gpu_name)

Execution Details

  • Execution reason: Initial execution
  • Dependencies: cupy
  • Final result: NVIDIA GeForce RTX 3050 Ti Laptop GPU
  • Build Time: 252.99s
  • Run Time: 6.05s
  • Execution Time: 259.10s
  • Total Time: 266.87s
  • Files:
    • /display_output/notebook_executed.ipynb
LLM backend
TaskFunctionModel
Generate codeprompt_scadsai_llmopenai/gpt-oss-120b
Fix codeprompt_scadsai_llmopenai/gpt-oss-120b
Determine dependenciesprompt_scadsai_llmopenai/gpt-oss-120b
Generate code feedbackprompt_scadsai_llmgoogle/gemma-4-31B-it
Summarize codeprompt_scadsai_llmopenai/gpt-oss-120b
Notebook conversionprompt_scadsai_llmopenai/gpt-oss-120b

The expected resulting GPU name is stored in this variable:

result.final_result
'NVIDIA GeForce RTX 3050 Ti Laptop GPU'

The code which determined the GPU name can be inspected like this:

print(result.code)
import cupy as cp

# Get the current device ID
device_id = cp.cuda.Device().id

# Retrieve device properties (includes the GPU name)
props = cp.cuda.runtime.getDeviceProperties(device_id)

# The 'name' field may be bytes; decode if needed
gpu_name = props["name"]
if isinstance(gpu_name, bytes):
    gpu_name = gpu_name.decode()

# Second‑last print: description
print("GPU name (detected by CuPy):")

# Last print: the result only
print(gpu_name)