Meta’s latest breakthrough in world models, V-JEPA 2 (Video Joint Embedding Predictive Architecture 2), is here to expand the abilities of visual understanding and physical-world prediction. It is trained on over a million hours of video and powered by Meta’s JEPA architecture, and as a 1.2B-parameter world model, this model excels in recognizing objects, predicting future frames, and enabling zero-shot robot planning, without requiring prior exposure to specific environments. With benchmarks like Something-Something v2 (SSV2) and Epic-Kitchens-100 under its belt, V-JEPA 2 is a powerful system capable of simulating the consequences of hypothetical actions and planning complex sequences in new surroundings. This makes it a game-changer for anyone building AI agents, robotics applications, or video-based understanding systems. If you’re a researcher, ML engineer, or into Robotics, understanding how to get this model running locally or on the cloud is the first step toward building the next generation of intelligent, real-physical-world-interacting AI.
In this guide, you’ll learn exactly how to install and run V-JEPA 2, irrespective of if you’re setting it up on your local machine or deploying it in a scalable cloud environment.
Prerequisites
The minimum system requirements for running this model are:
Step-by-step process to install and run V-JEPA 2
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.
Step 2: Create a GPU Node
After accessing your account, you should see a dashboard (see image), now:
- Navigate to the menu on the left side.
- Click on the GPU Nodes option.
- Click on Start to start creating your very first GPU node.
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)
- For this tutorial, we’ll be using 1x RTX A6000 GPU, however, you can choose any GPU as per the prerequisites.
- 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.
Step 4: Choose GPU Configuration and Authentication method
- After selecting your required configuration options, you’ll see the available GPU nodes in your region and according to (or very close to) your configuration. In our case, we’ll choose a 1x RTX A6000 48GB GPU node with 64vCPUs/63GB RAM/200GB SSD.
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.
Step 5: Choose an Image
The final step is to choose an image for the VM, which in our case is Nvidia Cuda.
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.
Step 6: Connect to active Compute Node using SSH
- 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!
- Once your GPU shows this status, navigate to the three dots on the right, click on Connect with SSH, and copy the SSH details that appear.
As you copy the details, follow the below steps to connect to the running GPU VM via SSH:
- Open your terminal, paste the SSH command, and run it.
2. In some cases, your terminal may take your consent before connecting. Enter ‘yes’.
3. A prompt will request a password. Type the SSH password, and you should be connected.
Output:
Next, If you want to check the GPU details, run the following command in the terminal:
!nvidia-smi
Step 7: Set up the project environment with dependencies
- Create a virtual environment using Anaconda.
conda create -n vjepa python=3.12 -y && conda activate vjepa
Output:
2. Once you’re inside the environment, install necessary dependencies to run the model.
pip install torch torchvision torchaudio einops timm pillow
pip install git+https://github.com/huggingface/transformers
pip install git+https://github.com/huggingface/accelerate
pip install git+https://github.com/huggingface/diffusers
pip install huggingface_hub
pip install sentencepiece bitsandbytes protobuf decord numpy
Output:
3. Clone the official repository of facebookresearch/vjepa2
and move inside the project directory.
git clone https://github.com/facebookresearch/vjepa2.git && cd vjepa2
Output:
4. Install all the required project dependencies.
pip install -e .
Output:
5. Also, install libgl1
if not present in the system.
sudo apt update
sudo apt install -y libgl1
6. Login to Hugging Face CLI with HF READ access token.
(Enter your HF READ access token when prompted)
huggingface-cli login
Output:
7. Install and run jupyter notebook.
conda install -c conda-forge --override-channels notebook -y
conda install -c conda-forge --override-channels ipywidgets -y
jupyter notebook --allow-root
8. If you’re on a remote machine (e.g., NodeShift GPU), you’ll need to do SSH port forwarding in order to access the jupyter notebook session on your local browser.
Run the following command in your local terminal after replacing:
<YOUR_SERVER_PORT>
with the PORT allotted to your remote server (For the NodeShift server – you can find it in the deployed GPU details on the dashboard).
<PATH_TO_SSH_KEY>
with the path to the location where your SSH key is stored.
<YOUR_SERVER_IP>
with the IP address of your remote server.
ssh -L 8888:localhost:8888 -p <YOUR_SERVER_PORT> -i <PATH_TO_SSH_KEY> root@<YOUR_SERVER_IP>
Output:
After this copy the URL you received in your remote server:
And paste this on your local browser to access the Jupyter Notebook session.
Step 8: Download and Run the model
- Open a Python notebook inside Jupyter.
2. In the first cell, define helper functions.
import json
import os
import subprocess
import numpy as np
import torch
import torch.nn.functional as F
from decord import VideoReader
from transformers import AutoVideoProcessor, AutoModel
import src.datasets.utils.video.transforms as video_transforms
import src.datasets.utils.video.volume_transforms as volume_transforms
from src.models.attentive_pooler import AttentiveClassifier
from src.models.vision_transformer import vit_giant_xformers_rope
IMAGENET_DEFAULT_MEAN = (0.485, 0.456, 0.406)
IMAGENET_DEFAULT_STD = (0.229, 0.224, 0.225)
def load_pretrained_vjepa_pt_weights(model, pretrained_weights):
# Load weights of the VJEPA2 encoder
# The PyTorch state_dict is already preprocessed to have the right key names
pretrained_dict = torch.load(pretrained_weights, weights_only=True, map_location="cpu")["encoder"]
pretrained_dict = {k.replace("module.", ""): v for k, v in pretrained_dict.items()}
pretrained_dict = {k.replace("backbone.", ""): v for k, v in pretrained_dict.items()}
msg = model.load_state_dict(pretrained_dict, strict=False)
print("Pretrained weights found at {} and loaded with msg: {}".format(pretrained_weights, msg))
def load_pretrained_vjepa_classifier_weights(model, pretrained_weights):
# Load weights of the VJEPA2 classifier
# The PyTorch state_dict is already preprocessed to have the right key names
pretrained_dict = torch.load(pretrained_weights, weights_only=True, map_location="cpu")["classifiers"][0]
pretrained_dict = {k.replace("module.", ""): v for k, v in pretrained_dict.items()}
msg = model.load_state_dict(pretrained_dict, strict=False)
print("Pretrained weights found at {} and loaded with msg: {}".format(pretrained_weights, msg))
def build_pt_video_transform(img_size):
short_side_size = int(256.0 / 224 * img_size)
# Eval transform has no random cropping nor flip
eval_transform = video_transforms.Compose(
[
video_transforms.Resize(short_side_size, interpolation="bilinear"),
video_transforms.CenterCrop(size=(img_size, img_size)),
volume_transforms.ClipToTensor(),
video_transforms.Normalize(mean=IMAGENET_DEFAULT_MEAN, std=IMAGENET_DEFAULT_STD),
]
)
return eval_transform
def get_video():
vr = VideoReader("sample_video.mp4")
# choosing some frames here, you can define more complex sampling strategy
frame_idx = np.arange(0, 128, 2)
video = vr.get_batch(frame_idx).asnumpy()
return video
def forward_vjepa_video(model_hf, hf_transform):
# Run a sample inference with VJEPA
with torch.inference_mode():
# Read and pre-process the image
video = get_video() # T x H x W x C
video = torch.from_numpy(video).permute(0, 3, 1, 2) # T x C x H x W
x_hf = hf_transform(video, return_tensors="pt")["pixel_values_videos"].to("cuda")
# Extract the patch-wise features from the last layer
out_patch_features_hf = model_hf.get_vision_features(x_hf)
return out_patch_features_hf
def get_vjepa_video_classification_results(classifier, out_patch_features_pt):
SOMETHING_SOMETHING_V2_CLASSES = json.load(open("ssv2_classes.json", "r"))
with torch.inference_mode():
out_classifier = classifier(out_patch_features_pt)
print(f"Classifier output shape: {out_classifier.shape}")
print("Top 5 predicted class names:")
top5_indices = out_classifier.topk(5).indices[0]
top5_probs = F.softmax(out_classifier.topk(5).values[0]) * 100.0 # convert to percentage
for idx, prob in zip(top5_indices, top5_probs):
str_idx = str(idx.item())
print(f"{SOMETHING_SOMETHING_V2_CLASSES[str_idx]} ({prob}%)")
return
3. Download sample video for testing and SSV2
classes from SSV2
dataset.
sample_video_path = "sample_video.mp4"
# Download the video if not yet downloaded to local path
if not os.path.exists(sample_video_path):
video_url = "https://huggingface.co/datasets/nateraw/kinetics-mini/resolve/main/val/bowling/-WH-lxmGJVY_000005_000015.mp4"
command = ["wget", video_url, "-O", sample_video_path]
subprocess.run(command)
print("Downloading video")
# Download SSV2 classes if not already present
ssv2_classes_path = "ssv2_classes.json"
if not os.path.exists(ssv2_classes_path):
command = [
"wget",
"https://huggingface.co/datasets/huggingface/label-files/resolve/d79675f2d50a7b1ecf98923d42c30526a51818e2/"
"something-something-v2-id2label.json",
"-O",
"ssv2_classes.json",
]
subprocess.run(command)
print("Downloading SSV2 classes")
4. Download model checkpoints and run the model for inference.
# HuggingFace model repo name
hf_model_name = (
"facebook/vjepa2-vitg-fpc64-384" # Replace with your favored model, e.g. facebook/vjepa2-vitg-fpc64-384
)
# Initialize the HuggingFace model, load pretrained weights
model_hf = AutoModel.from_pretrained(hf_model_name)
model_hf.cuda().eval()
# Build HuggingFace preprocessing transform
hf_transform = AutoVideoProcessor.from_pretrained(hf_model_name)
img_size = hf_transform.crop_size["height"] # E.g. 384, 256, etc.
# Inference on video to get the patch-wise features
out_patch_features_hf = forward_vjepa_video(
model_hf, hf_transform
)
print(
f"""
Inference results on video:
HuggingFace output shape: {out_patch_features_hf.shape}
"""
)
# Download classifier weights if not present
classifier_model_path = "./ssv2-vitg-384-64x2x3.pt"
if not os.path.exists(classifier_model_path):
command = ["wget", "https://dl.fbaipublicfiles.com/vjepa2/evals/ssv2-vitg-384-64x2x3.pt", "-O", classifier_model_path]
subprocess.run(command)
# Initialize the classifier
classifier = AttentiveClassifier(embed_dim=1408, num_heads=16, depth=4, num_classes=174).cuda().eval()
# Load classifier weights
pretrained_dict = torch.load(classifier_model_path, weights_only=True, map_location="cpu")["classifiers"][0]
pretrained_dict = {k.replace("module.", ""): v for k, v in pretrained_dict.items()}
msg = classifier.load_state_dict(pretrained_dict, strict=False)
print("Pretrained weights found and loaded with msg: {}".format(msg))
# Get classification results
get_vjepa_video_classification_results(classifier, out_patch_features)
Here’s the output generated by the model for the given video:
Video Input:
Output:
Conclusion
In this article, we explored the transformative capabilities of Meta’s V-JEPA 2, a cutting-edge world model built for video-based understanding, prediction, and zero-shot robot planning in dynamic physical environments. From its self-supervised learning on massive video datasets to its performance on state-of-the-art benchmarks, V-JEPA 2 represents a major step towards building truly intelligent AI agents and AI robots. And with NodeShift, deploying such powerful models becomes effortless, offering a seamless, scalable environment for experimentation, fine-tuning, and real-world integration.