Skip to content

Run Juice

dave-juicelabs edited this page Jul 20, 2023 · 9 revisions

Run an application with Juice by launching it through the juicify command line tool, passing the path to the application and any arguments on the command line.

For example, assuming the directory you extracted the client archive to is included in PATH the following will run <application> with Juice:

juicify <application>

See Juice for Compute for examples of running ResNet, YOLO, and Stable Diffusion with Juice.

See Juice for Graphics for examples of running graphical applications with Juice, e.g. 3DMark, Superposition, Maya, and more. Graphics workloads are currently only supported from the Windows client. NOTE: This is a client-side restriction only -- the Juice client on Windows can connect to a Juice server running on Linux or Windows to serve graphics workloads.

Juice for Compute

These examples assume that you are running from a command prompt or shell with juicify available in the path, e.g. with the directory you extracted the Juice client archive to listed in the PATH environment variable.

PyTorch

Juice can accelerate PyTorch applications with a remote GPU. For example run the sample image classification applications for ResNet and YOLOv5 with Juice by launching them through the juicify command line tool:

ResNet

There are examples of running ResNet and YOLO with PyTorch in an Anaconda environment included with the Juice client archive. To run these examples install Anaconda, re-open your shell after installation, and then run the following from the directory you extracted the Juice client archive to.

Create an Anaconda environment and install the latest PyTorch with CUDA 11.7 support:

conda create -n juice
conda activate juice
conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia

Run the ResNet example with Juice:

juicify python pytorch/resnet.py

When you see a result like:

Juice GPU
Using cache found in C:\Users\charles/.cache\torch\hub\pytorch_vision_v0.9.0
Samoyed 0.7907482981681824
Pomeranian 0.08977659046649933
white wolf 0.0361027754843235
keeshond 0.02681436948478222
Arctic fox 0.022788094356656075

... you've confirmed that Juice is working for ResNet.

YOLO

Install extra dependencies required by YOLO in the same Anaconda environment before running the YOLO example:

pip install -r pytorch/requirements.txt

Run the YOLO example with Juice from the Anaconda prompt:

juicify python pytorch/yolo.py

When you see a result like:

Juice GPU
Using cache found in C:\Users\charles/.cache\torch\hub\ultralytics_yolov5_master
YOLOv5  2022-7-19 Python-3.10.6 torch-1.11.0 CUDA:0 (Juice GPU, 8192MiB)

Fusing layers...
YOLOv5s summary: 213 layers, 7225885 parameters, 0 gradients
Adding AutoShape...
image 1/1: 720x1280 2 persons, 2 ties
Speed: 1185.4ms pre-process, 54.8ms inference, 184.0ms NMS per image at shape (1, 3, 384, 640)

... you've confirmed that Juice is working for YOLO.

Stable Diffusion

Set up AUTOMATIC1111/stable-diffusion-webui:

  1. Install Python 3.10.6 sudo apt install python3.10 python3.10-venv
  2. Install Git sudo apt install git
  3. Clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
  4. Download sd-v1-4.ckpt to stable-diffusion-webui/models/Stable-diffusion
  5. Download GFPGANv1.4.pth to stable-diffusion-webui

Run Stable Diffusion with Juice on Windows:

juicify webui.bat

Run Stable Diffusion with Juice on Linux:

juicify webui.sh

Browse to http://127.0.0.1:7860 to view the user interface and generate images.

MLPerf

Inference

The following instructions can be used to run the MLPerf Inference benchmark using Juice. These instructions assume the use of Tensorflow and ResNet50 on a Debian based system specifically running the classification_and_detection benchmark.

Install the following system wide packages.

sudo apt install -y git gcc g++ python3.10 python3.10-dev wget unzip

Checkout the reference MLPerf Inference benchmark (r2.1)

git clone -b r2.1 --recurse-submodules https://github.com/mlcommons/inference.git
cd inference/vision/classification_and_detection

We'll install the dependencies in a conda environment. You'll need Anaconda installed. In a shell with conda activated run the following.

conda create -n inference
conda activate inference
# Tensorflow
conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib/
mkdir -p $CONDA_PREFIX/etc/conda/activate.d
echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib/' > $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh
# MLPerf Inference setup
pip install --upgrade pip
pip install tensorflow pillow onnx opencv-python-headless Cython pycocotools pybind11
pip install -e ../../loadgen/
mkdir models
wget https://zenodo.org/record/2535873/files/resnet50_v1.pb -O models/resnet50_v1.pb

We'll run with fake_imagenet data, run

./tools/make_fake_imagenet.sh

export MODEL_DIR=$PWD/models
export DATA_DIR=$PWD/fake_imagenet

To use imagenet override DATA_DIR to the location of your verification layout.

Run the benchmark by running

juicify ./run_local.sh tf resnet50 gpu

Juice for Graphics

These examples assume that you are running from a command prompt or shell with juicify available in the path, e.g. with the directory you extracted the Juice client archive to listed in the PATH environment variable.

The graphics examples must be run on Windows, Juice doesn't currently support graphics workloads from Linux clients. This is a client-side restriction only -- The Juice server runs equally well on Windows and Linux and clients from either operating system can connect to servers running on either operating system.

vkcube

A good test that everything is working is to run the vkcube example included with the client software. From a command prompt in the directory that you extracted the client archive to:

juicify vkcube

As graphical applications are running, you should see the Juice heads-up-display in the upper left corner of the window. You're experiencing Juice GPU-over-IP! Try running multiple clients to the same server - shared GPU is also a unique capability of Juice.

3DMark

Run 3DMark with Juice:

juicify "C:\Program Files\UL\3DMark\3DMark.exe"

You can run the Steam version of 3DMark by providing the Steam App ID in a file named steam_appid.txt in the same directory as the 3DMark executable. See the Steam section for more details:

Superposition

Run Superposition with Juice:

juicify "C:\Program Files\Unigine\Superposition Benchmark\Superposition.exe"

Maya

Run Maya with Juice:

juicify "C:\Program Files\Autodesk\Maya2022\bin\maya.exe"

Blender

Run Blender with Juice:

juicify "C:\Program Files\Blender Foundation\Blender 2.93\blender.exe"

Steam

Steam games and applications often require a running Steam client in order to run. This can be tricky when launching from the command line with juicify. That said many games do work and there's no harm in trying. There are three methods you can use to launch Steam games with Juice:

  1. Launch the game from the command line with juicify
  2. Place the Steam App ID in steam_appid.txt and launch with juicify
  3. Close and relaunch Steam with juicify

Launch with juicify:

Games that allow launching without Steam, e.g. Cyberpunk 2077, can be launched with juicify without any extra steps. This is the easiest method if it works and you should try this first.

Place Steam App ID in steam_appid.txt and launch with juicify:

Games that report being unable to connect to the Steam client when run directly from the command line often run once their Steam App ID is placed in a file named steam_appid.txt in the same directory as the game executable. A game's Steam App ID is the six digit number shown on the game's UPDATES page in the Steam library, click on the gears icon (Manage) > Properties > UPDATES.

Close and relaunch Steam with juicify:

Games that won't launch with Juice by the above two methods might work when Steam is launched with juicify. Quit Steam completely and relaunch with juicify. After this anything launched through Steam will use Juice.

juicify "C:\Program Files (x86)\Steam\steam.exe"

Cyberpunk 2077

Cyberpunk 2077 launches directly with Juice, no extra steps needed.

juicify "C:\Program Files (x86)\Steam\steamapps\common\Cyberpunk 2077\bin\x64\Cyberpunk2077.exe"

Doom

Run the Vulkan version of Doom 2016 with Juice after creating C:\Program Files (x86)\Steam\steamapps\common\DOOM\steam_appid.txt with the Steam App ID for your Steam install of Doom 2016:

juicify "C:\Program Files (x86)\Steam\steamapps\common\DOOM\DOOMx64vk.exe"

NOTE: Juice specifically supports the Vulkan version of DOOM 2016 so you'll need to make sure that you're running the Vulkan executable DOOMx64vk.exe and have configured Doom to use Vulkan.

3DMark via Steam

Run 3DMark benchmark installed via Steam with Juice after creating C:\Program Files (x86)\Steam\steamapps\common\3DMark\bin\x64\steam_appid.txt with the Steam App ID for your Steam install of 3DMark:

juicify "C:\Program Files (x86)\Steam\steamapps\common\3DMark\bin\x64\3DMark.exe"