Skip to content

[Bug] Studio GPU selection ignores 3rd GPU — selects [0,1] with fit: False instead of expanding to all 3 #5680

Closed

Description

@lbeischer

Note: Please do not remove the questions. Answer beside them.

  1. Did you update? pip install --upgrade unsloth unsloth_zoo: Yes latest install
  2. Colab or Kaggle or local / cloud: Local
  3. Number GPUs used, use nvidia-smi: 3 are present, only 2 are loading (as per bug)
  4. Which notebook? Just the unsloth studio
  5. Which Unsloth version, TRL version, transformers version, PyTorch version? unsloth 26.5.5
  6. Which trainer? SFTTrainer, GRPOTrainer etc N/A

Environment

Bug
Studio correctly detects all 3 GPUs but only selects 2, logging fit: False instead of expanding to the third:

GGUF size: 24.2 GB, est. KV cache: 3.8 GB, context: 58368,
GPUs free: [(0, 15945), (1, 15945), (2, 15945)], selected: [0, 1], fit: False

With 3x ~15.9GB GPUs = ~47GB total VRAM, the model + KV cache (~28GB) should fit across all 3. Studio appears to stop at 2 GPUs even when fit: False and a third GPU is available, rather than expanding the selection.
Expected behaviour: When fit fails across N GPUs and additional GPUs are available, Studio should expand selection to N+1.

I was also expecting equal load across all 3 GPUs this is not the case

Workaround: Trying to pass --tensor-split 1,1,1 via unsloth run extra args forces all 3 GPUs to be used.

Activity

  1. lbeischer commented on May 22, 2026

    @lbeischer
    Author

    Root cause confirmed:

    Studio's GPU selection logic picks [0, 1] and then launches llama-server with CUDA_VISIBLE_DEVICES=0,1 internally. This means any external override — including CUDA_VISIBLE_DEVICES=0,1,2 in the systemd service Environment= block, /etc/environment, or ~/.bashrc — is ignored because Studio's own selection takes precedence at launch time.

    Confirmed by inspecting the llama-server log directly:

    0.00.266.430 I   - CUDA0   : NVIDIA GeForce RTX 4060 Ti (15947 MiB, 15819 MiB free)
    0.00.390.385 I   - CUDA1   : NVIDIA GeForce RTX 4060 Ti (15947 MiB, 15819 MiB free)
    

    GPU 2 is completely absent from llama-server's device list.

    Things tried that did not work:

    • Environment="CUDA_VISIBLE_DEVICES=0,1,2" in systemd service file
    • echo 'CUDA_VISIBLE_DEVICES=0,1,2' >> /etc/environment
    • Passing --tensor-split 1,1,1 --n-gpu-layers 999 as extra args via unsloth run — these are appended after Studio's own flags but llama-server never sees GPU 2 to split across
  2. Datta0 commented on May 22, 2026

    @Datta0
    Contributor

    Hey @lbeischer the idea is to pick the minimul number of GPUs possible for the task so that communication delays are avoided and the performance is faster

  3. lodm94 commented on May 22, 2026

    @lodm94

    Hi, i would like to setup a similar environment. I'm on a server with 2xH100 and used to launch fine-tuning environment via Unsloth docker image. Still DDP is not working. It seems you can train on at least 2 GPUs using Unsloth studio. How did you setup the environment? I tried performing these steps: https://unsloth.ai/docs/basics/multi-gpu-training-with-unsloth/ddp but its not working.
    It's not clear where I should start: ubuntu image? nvidia cuda devel image? Some image with torch already installed? Which CUDA version?
    I tried installing as per the guide on an image nvidia cuda devel 13.0.2 with python 3.10, but got:

    Processing /workspace/unsloth
      Installing build dependencies ... done
      Getting requirements to build wheel ... done
      Installing backend dependencies ... done
      Preparing metadata (pyproject.toml) ... done
    Building wheels for collected packages: UNKNOWN
      Building wheel for UNKNOWN (pyproject.toml) ... done
      Created wheel for UNKNOWN: filename=UNKNOWN-0.0.0-py3-none-any.whl size=17245 sha256=f91133a8c70e69f987ef0b4c8df63e4e6c6561ea5b47b3e7b93e0d092d4dba72
      Stored in directory: /tmp/pip-ephem-wheel-cache-8nn_f1ms/wheels/ba/d4/22/1254f43efc75091d68d260956ee9fb01480a2dc07fceeb60a5
    Successfully built UNKNOWN
    Installing collected packages: UNKNOWN
    Successfully installed UNKNOWN-0.0.0
    
  4. lbeischer commented on May 22, 2026

    @lbeischer
    Author

    Hey @lbeischer the idea is to pick the minimul number of GPUs possible for the task so that communication delays are avoided and the performance is faster

    Thanks @Datta0 and makes sense as a general principle however in this case studio logged fit: False after selecting [0, 1]:

    GGUF size: 23.9 GB, est. KV cache: 4.1 GB, context: 67840,
    GPUs free: [(0, 15945), (1, 15945), (2, 15945)], selected: [0, 1], fit: False
    

    If the goal is to use the minimum number of GPUs, the selection logic should be:

    1. Try N GPUs
    2. If fit: False, expand to N+1
    3. Repeat until fit succeeds or all GPUs are exhausted

    Instead, Studio selects [0, 1], determines fit: False, then proceeds anyway without expanding to GPU 2 — which has 15,945 MiB free and would provide the headroom needed. The result is the model loads across 2 GPUs with insufficient VRAM, causing OOM crashes under load.

    If the intended behaviour is truly minimum GPUs, then fit: False should never be an acceptable outcome when additional GPUs are available.

  5. danielhanchen commented on Jul 14, 2026

    @danielhanchen
    Member

    This should be fixed now - sorry on the delay - please update Unsloth Studio to the latest via curl -fsSL https://unsloth.ai/install.sh | sh for Linux, Mac, WSL or irm https://unsloth.ai/install.ps1 | iex for Windows - if it's not fixed yet, it'll be in the next Studio release - if it's still not working after that, please open another issue - appreciate it again!

    Fixed in #6718 and #6940, which reserve per-device compute and context so multi-GPU GGUF fit uses all GPUs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions