Repository navigation
Description
Hi there, thank you for the great work on Unsloth! I am trying to install the package in a Docker containers to fine-tune Gemma models following the Colab notebooks for Gemma:
https://colab.research.google.com/drive/1vIrqH5uYDQwsJ4-OO3DErvuv4pBgVwk4?usp=sharing
I am working with a Docker file (below) where I am trying to emulate the package versions in the Colab runtime, which is torch==2.5 and unsloth==2024.10.7.
FROM pytorch/pytorch:2.5.0-cuda12.1-cudnn9-runtime
# Below command creates home dir for 1000 UID user if it is not present.
RUN if ! id 1000; then useradd -m -u 1000 clouduser; fi
RUN mkdir /workdir
WORKDIR /workdir
ENV LANG=C.UTF-8
RUN apt-get update --allow-releaseinfo-change && apt-get install -y git python3 python3-pip netcat
RUN python3 -m pip install --upgrade pip
# Below command installs required libraries
COPY requirements.txt /workdir/pytorch_xcloud_training/requirements.txt
RUN python3 -m pip --no-cache-dir install -r pytorch_xcloud_training/requirements.txt
RUN python3 -m pip install peft==0.13.2
# Below command installs unsloth
RUN python3 -m pip install "unsloth[cu121-torch250] @ git+https://github.com/unslothai/unsloth.git"
RUN python3 -m pip install unsloth-zoo
# Install flash attention library
RUN python3 -m pip install flash-attn --no-build-isolation
COPY train_C2S_unsloth_HF_torch_lora.py /workdir/pytorch_xcloud_training/train_C2S_unsloth_HF_torch_lora.py
# Below command make 1000 UID and root user as owners of the workdir.
RUN chown -R 1000:root /workdir && chmod -R 775 /workdir
ENTRYPOINT ["python3", "-m", "pytorch_xcloud_training.train_C2S_unsloth_HF_torch_lora"]
I have been running into errors with my pip installation for a while now in the call to model = FastLanguageModel.get_peft_model():
TypeError: empty() received an invalid combination of arguments - got (tuple, dtype=NoneType, device=NoneType), but expected one of:
* (tuple of ints size, *, tuple of names names, torch.memory_format memory_format = None, torch.dtype dtype = None, torch.layout layout = None, torch.device device = None, bool pin_memory = False, bool requires_grad = False)
* (tuple of ints size, *, torch.memory_format memory_format = None, Tensor out = None, torch.dtype dtype = None, torch.layout layout = None, torch.device device = None, bool pin_memory = False, bool requires_grad = False)
I am unsure of what is causing this error. I am able to create a working Anaconda environment following the Anaconda installation instructions in the ReadME, and the Colab runs, however any Docker environment I create runs into this error. Any advice on this would be greatly appreciated!
Activity
danielhanchen commentedon Oct 26, 2024
@SyedA5688 Wait we don't yet have a Torch 2.5 tag yet - probably best to just use
unslothwithout the tagSyedA5688 commentedon Oct 27, 2024
I see, thanks for your quick reply! I've gotten farther along with trying to build a Docker container with torch 2.5 and unsloth, however I still run into the above error. Is there a Docker image available for unsloth by any chance that I could base my image off of?
danielhanchen commentedon Oct 27, 2024
@SyedA5688 One way is to use the vLLM Docker image, and add Unsloth together (although vLLM doesn't yet support torch 2.5)
Also I just added
unsloth[cu121-torch250]as well!SyedA5688 commentedon Oct 27, 2024
Thank you for updating to torch 2.5!
After some more experimenting with Docker files, I have landed on this Docker file based on some other posts:
When I run with this Docker file, all libraries seem set up correctly (no errors with CUDA or flash attention), however I still run into the same error as I mentioned above:
This error occurs in the call to FastLanguageModel.get_peft_model(). Full stack trace:
This error does not come up when running Unsloth Gemma-2 LoRA training in Google colab (torch 2.5.0+cu121 and unsloth 2024.10.7) or Anaconda environments I tried on other Linux machines (which had pytorch 2.4.1 and unsloth 2024.10.0). Any idea what might be causing this particular error?
SyedA5688 commentedon Oct 27, 2024
Update: after some more debugging, I found out the issue:
I was passing in lora_rank (r) = 16.0, which is a float, rather than an integer; the error made it hard to spot that I had my types incorrect for the argument. When I passed in 16, the error was resolved.
Closing this issue, thank you for your responsiveness!