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
| Task | Function | Model |
|---|---|---|
| Generate code | prompt_scadsai_llm | openai/gpt-oss-120b |
| Fix code | prompt_scadsai_llm | openai/gpt-oss-120b |
| Determine dependencies | prompt_scadsai_llm | openai/gpt-oss-120b |
| Generate code feedback | prompt_scadsai_llm | google/gemma-4-31B-it |
| Summarize code | prompt_scadsai_llm | openai/gpt-oss-120b |
| Notebook conversion | prompt_scadsai_llm | openai/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)