DEV Community

Cover image for How to Install Tulu 3 8B DPO Locally
Aditi Bindal for NodeShift

Posted on

How to Install Tulu 3 8B DPO Locally

Tulu-3-8B-DPO opens up endless possibilities for developers, researchers, and AI enthusiasts who want direct access to a high-performance, instruction-following language model. This state-of-the-art model is designed for diverse tasks, excelling in areas such as mathematical problem-solving, advanced logic, and reasoning-based datasets. It is built on Llama-3.1 architecture and fine-tuned with open-source, human-created, and synthetic datasets. This model stands out as a versatile and accessible choice for machine learning experiments, surpassing popular LLMs like GPT4o and DeepSeek V3 in many places. Unlike other models that come with restrictive licensing and proprietary limitations, Tulu-3-8B-DPO is fully open-source, allowing seamless customization and development.

This guide walks you through the complete installation process for deploying Tulu-3-8B-DPO locally, offering hands-on steps to get the model running efficiently on your setup.

Prerequisites

The minimum system requirements for this use case are:

  • GPUs: RTX 4090 or RTX A6000 (for smooth execution).

  • Disk Space: 200 GB

  • RAM: At least 8 GB.

  • Jupyter Notebook installed.

Note: The prerequisites for this are highly variable across use cases. A high-end configuration could be used for a large-scale deployment.

Step-by-step process to install & run Tulu-3-8B-DPO locally

For the purpose of this tutorial, we’ll use a GPU-powered Virtual Machine by NodeShift since it provides high compute Virtual Machines at a very affordable cost on a scale that meets GDPR, SOC2, and ISO27001 requirements. Also, it offers an intuitive and user-friendly interface, making it easier for beginners to get started with Cloud deployments. However, feel free to use any cloud provider of your choice and follow the same steps for the rest of the tutorial.

Step 1: Setting up a NodeShift Account

Visit app.nodeshift.com and create an account by filling in basic details, or continue signing up with your Google/GitHub account.

If you already have an account, login straight to your dashboard.

Image-step1-1

Step 2: Create a GPU Node

After accessing your account, you should see a dashboard (see image), now:

1) Navigate to the menu on the left side.

2) Click on the GPU Nodes option.

Image-step2-1

3) Click on Start to start creating your very first GPU node.

Image-step2-2

These GPU nodes are GPU-powered virtual machines by NodeShift. These nodes are highly customizable and let you control different environmental configurations for GPUs ranging from H100s to A100s, CPUs, RAM, and storage, according to your needs.

Step 3: Selecting configuration for GPU (model, region, storage)

1) For this tutorial, we’ll be using the RTX 4090 GPU; however, you can choose any GPU of your choice based on your needs.

2) Similarly, we’ll opt for 200GB storage by sliding the bar. You can also select the region where you want your GPU to reside from the available ones.

Image-step3-1

Step 4: Choose GPU Configuration and Authentication method

1) After selecting your required configuration options, you'll see the available VMs in your region and according to (or very close to) your configuration. In our case, we'll choose a 1x RTX 4090 GPU node with 12 vCPUs/96GB RAM/200 GB SSD.

Image-step4-1

2) Next, you'll need to select an authentication method. Two methods are available: Password and SSH Key. We recommend using SSH keys, as they are a more secure option. To create one, head over to our official documentation.

Image description

Step 5: Choose an Image

The final step would be to choose an image for the VM, which in our case is Jupyter Notebook, where we’ll deploy and run the inference of our model.

Image-step5-1

That's it! You are now ready to deploy the node. Finalize the configuration summary, and if it looks good, click Create to deploy the node.

Image-step5-2

Image-step5-3

Step 6: Connect to active Compute Node using SSH

1) As soon as you create the node, it will be deployed in a few seconds or a minute. Once deployed, you will see a status Running in green, meaning that our Compute node is ready to use!

2) Once your GPU shows this status, navigate to the three dots on the right and click on Connect with SSH. This will open a new tab with a Jupyter Notebook session in which we can run our model.

Image-step6-1

Step 7: Setting up Python Notebook

Start by creating a .ipynb notebook by clicking on Python 3 (ipykernel)

Image-step7-1

Next, If you want to check the GPU details, run the following command in the Jupyter Notebook cell:

!nvidia-smi
Enter fullscreen mode Exit fullscreen mode

Output:

Image-step7-1

Step 8: Install Dependencies

Install the following dependency packages to run the model.

!pip install torch
!pip install git+https://github.com/huggingface/transformers
!pip install git+https://github.com/huggingface/accelerate
!pip install huggingface_hub
Enter fullscreen mode Exit fullscreen mode

Output:

Image-step8-1

Step 9: Load and run the model

After completing the above setup, we can proceed with loading and importing the model. It may take some time to download completely, depending on your compute resources.

1) Here's the code snippet for downloading and importing the model:

import transformers
import torch
from IPython.display import Markdown, display

model_id = "allenai/Llama-3.1-Tulu-3-8B-DPO"

pipeline = transformers.pipeline(
    "text-generation",
    model=model_id,
    model_kwargs={"torch_dtype":torch.bfloat16},
    device_map="auto",
)
Enter fullscreen mode Exit fullscreen mode

Output:

Image-step9-1

2) Once the model has finished downloading, we'll test the model with the following snippet:

prompt="""
Write a short story about a community garden in a small town where neighbors come together
to overcome a minor conflict and learn about cooperation. 
"""
messages = [
    {"role": "system", "content":"You are Tulu 3, a helpful and harmless AI assistant built by the Allen Institute of AI."},
    {"role": "user", "content": prompt},
]

outputs=pipeline(messages,max_new_tokens=1024,)
output_text=outputs[0]["generated_text"][-1]['content']
display(Markdown(output_text))
Enter fullscreen mode Exit fullscreen mode

Output:

Image-step9-2

Image-step9-3

Image-step9-4

Conclusion

In this article, we've explored the step-by-step process of installing the Tulu-3-8B-DPO model locally, highlighting its powerful capabilities for instruction-following tasks and its open-source flexibility for customization. By following the outlined methods, developers can unlock the full potential of this model for research and experimentation. With NodeShift's robust and scalable infrastructure, deploying models like Tulu-3-8B-DPO becomes even more seamless, ensuring optimized performance, secure storage, and efficient resource management for AI workloads.

For more information about NodeShift:

Top comments (0)