Hello USD - Part 17: I'll build OpenUSD on my VM, how long could it take?

This article is part of a series.

I don’t want a GitHub Action to be the only way I find a problem with my code on Linux. If a test fails or the code won’t build I want to fix it in an environment with a faster feedback loop. I already have an Ubuntu VM already setup for Swift development and it’s time to install OpenUSD on it.

How’d this get to be a whole post all to itself??

This ended up taking ALL DAY, since SOMEONE decided to do this on a VM with only one processor allocated to it. Also, I had only ~80 MB to spare on my Virtual Machine when it was done! Whew. I’m using up about 3 more gigs of space now.

The number of cores matters because the python_build.py script actually does something pretty clever. They’ve designed it to run on multiple cores. make -j appears on lines 973, 982, 1033 with variables for the input, so somewhere else they’ve looked up the number of cores available. The -j option sets the number of subcommands allowed.

My build took so long because I gave this GIANT task, designed to work with multiple subprocesses, one measly wee little core. When installing OpenUSD a non VM, run the top command to see it throw itself a party.

To see how many processors a machine has available, run getconf _NPROCESSORS_ONLN (other ways)

ProTip: Update the settings next time!

What was on it before I started

Previously on the VM as documented on SwiftLIBPNG’s repo

A VirtualBox machine running Ubuntu 22.04.2

sudo apt update
sudo apt upgrade
sudo apt install clang libicu-dev build-essential pkg-config
apt install git gh
apt install libpng-dev
mkdir ~/swift
cd ~/swift
# go to https://www.swift.org/download/#releases for current links
wget https://download.swift.org/swift-5.8-release/ubuntu2004/swift-5.8-RELEASE/swift-5.8-RELEASE-ubuntu20.04.tar.gz
tar xzf swift-5.8-RELEASE-ubuntu20.04.tar.gz #add v (xzvf) to see all files
mv swift-5.8-RELEASE-ubuntu22.04 5.8
# swift.org recommended choice: add a simlink to `swift` command to `/usr/bin/` 
# instead of adding version folder to $PATH. 
sudo ln -s ~/swift/5.8/usr/bin/swift /usr/bin/swift 
swift --version

Building OpenUSD

Steps make a working usdview included build of OpenUSD

sudo apt install cmake # <==== Ended up being a mistake.  
python --version # 3.10.6, perfect
sudo apt install python3-pip
pip3 install PyOpenGL numpy Pyside6
#As per warning
export PATH=$PATH:/home/ubuntu_admin/.local/bin;
sudo apt-get install -y libgl1-mesa-dev libglu1-mesa-dev libxt-dev
cd ~/Documents/GitHub
git clone https://github.com/PixarAnimationStudios/OpenUSD.git
python3 OpenUSD/build_scripts/build_usd.py ~/opb/OpenUSD_2023JUL24_default

No Joy.

ERROR: CMake version 3.24 or later required to build USD, but version found was 3.22.1
# Remove previous cmake versions
sudo apt remove cmake
sudo apt purge --auto-remove cmake
hash -r #console refresh
sudo apt-get install build-essential libssl-dev libssl-doc
wget https://github.com/Kitware/CMake/releases/download/v3.27.0/cmake-3.27.0.tar.gz
tar xf cmake-3.27.0.tar.gz
cd cmake-3.27.0
./bootstrap
make 
sudo make install
hash -r
cmake --version

Afterwards python3 OpenUSD/build_scripts/build_usd.py ~/opb/OpenUSD_2023JUL24_default worked just fine. Took forever. Had to delete a bunch of stuff on the VM so it would fit, but worked just fine.

It works!

I switched the setup in USDTestingCLI.swift

//MARK: --------------------- YOUR SETUP GOES HERE ------------------------
let USDBuild = "/home/USERNAME/opb/OpenUSD_2023JUL24_default"
let pythonEnv:USDServiceProvider.PythonEnvironment = .systemDefault

And it works!

Screenshot of Ubuntu desktop with VSCode open to USDTestingCLI with the same output in the console as yesterday’s post had from the MacOS build.

usdview, too!

This article is part of a series.